Skip to content

Commit

Permalink
Cleanup stuff for 2.3.2 release.
Browse files Browse the repository at this point in the history
  • Loading branch information
LambdAurora committed Sep 11, 2023
1 parent 1596f33 commit 100de58
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 49 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,13 @@

### 2.3.2

- Fixed Fabric API (Indigo Renderer) compatibility
(by [#182](https://github.com/LambdAurora/LambDynamicLights/pull/182),
issue [#172](https://github.com/LambdAurora/LambDynamicLights/issues/172)).
- Fixed Sodium compatibility
(by [#178](https://github.com/LambdAurora/LambDynamicLights/pull/178),
issue [#175](https://github.com/LambdAurora/LambDynamicLights/issues/175)).
- Fixed Minecraft version restriction.
- Cleaned up some item light source code.

[SpruceUI]: https://github.com/LambdAurora/SpruceUI "SpruceUI page"
Expand Down
17 changes: 11 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
plugins {
id 'fabric-loom' version '1.2.+'
id 'fabric-loom' version '1.3.+'
id 'io.github.juuxel.loom-quiltflower' version '1.8.+'
id 'org.quiltmc.gradle.licenser' version '2.0.+'
id 'java-library'
id 'maven-publish'
id 'com.github.johnrengelman.shadow' version '7.1.2'
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'com.modrinth.minotaur' version '2.+'
id 'com.matthewprenger.cursegradle' version '1.4.+'
}
Expand All @@ -13,11 +13,16 @@ import com.modrinth.minotaur.dependencies.ModDependency

group = project.maven_group
version = "${project.mod_version}+${project.minecraft_version}"
archivesBaseName = project.archives_base_name
base.archivesName = project.archives_base_name

// This field defines the Java version your mod target.
def targetJavaVersion = 17

if (!(System.getenv("CURSEFORGE_TOKEN") || System.getenv("MODRINTH_TOKEN"))) {
version += "-local"
}
logger.lifecycle("Preparing version ${version}...")

boolean isMCVersionNonRelease() {
return project.minecraft_version.matches('^\\d\\dw\\d\\d[a-z]$')
|| project.minecraft_version.matches('\\d+\\.\\d+-(pre|rc)(\\d+)')
Expand Down Expand Up @@ -130,7 +135,7 @@ dependencies {
transitive = false
}

modImplementation "maven.modrinth:sodium:${project.sodium_version}"
modRuntimeOnly "maven.modrinth:sodium:${project.sodium_version}"

shadow 'com.electronwill.night-config:core:3.6.6'
shadow 'com.electronwill.night-config:toml:3.6.6'
Expand Down Expand Up @@ -159,7 +164,7 @@ processResources {

jar {
from('LICENSE') {
rename { "${it}_${project.archivesBaseName}" }
rename { "${it}_${base.archivesName}" }
}
}

Expand All @@ -171,7 +176,7 @@ license {
shadowJar {
dependsOn jar
configurations = [project.configurations.shadow]
destinationDirectory.set(file("${project.buildDir}/devlibs"))
destinationDirectory.set(file("${project.layout.buildDirectory.get()}/devlibs"))
archiveClassifier.set('dev')

relocate 'com.electronwill.nightconfig', 'dev.lambdaurora.lambdynlights.shadow.nightconfig'
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
8 changes: 6 additions & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -130,10 +131,13 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* LambDynamicLights mixin plugin for conditional mixins.
*
* @author LambdAurora
* @version 2.1.1
* @version 2.3.2
* @since 1.0.0
*/
public class LambDynLightsMixinPlugin implements IMixinConfigPlugin {
Expand All @@ -34,7 +34,7 @@ public LambDynLightsMixinPlugin() {
this.conditionalMixins.put("dev.lambdaurora.lambdynlights.mixin.ltr.LilTaterBlockEntityMixin", ltrInstalled);

boolean sodium05XInstalled = LambDynLightsCompat.isSodium05XInstalled();
this.conditionalMixins.put("dev.lambdaurora.lambdynlights.mixin.sodium.ArrayLightDataCache", sodium05XInstalled);
this.conditionalMixins.put("dev.lambdaurora.lambdynlights.mixin.sodium.ArrayLightDataCacheMixin", sodium05XInstalled);
this.conditionalMixins.put("dev.lambdaurora.lambdynlights.mixin.sodium.FlatLightPipelineMixin", sodium05XInstalled);
this.conditionalMixins.put("dev.lambdaurora.lambdynlights.mixin.sodium.LightDataAccessMixin", sodium05XInstalled);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import dev.lambdaurora.lambdynlights.LambDynLights;
import dev.lambdaurora.lambdynlights.util.SodiumDynamicLightHandler;
import me.jellysquid.mods.sodium.client.model.light.data.LightDataAccess;
import org.spongepowered.asm.mixin.Dynamic;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Pseudo;
Expand All @@ -21,16 +20,16 @@

@Pseudo
@Mixin(targets = "me.jellysquid.mods.sodium.client.model.light.data.ArrayLightDataCache", remap = false)
public abstract class ArrayLightDataCacheMixin extends LightDataAccess {
@Dynamic
@Inject(method = "get(III)I", at = @At("HEAD"))
private void lambdynlights$storeLightPos(int x, int y, int z, CallbackInfoReturnable<Integer> cir) {
if (!LambDynLights.get().config.getDynamicLightsMode().isEnabled())
return;
public abstract class ArrayLightDataCacheMixin {
@Dynamic
@Inject(method = "get(III)I", at = @At("HEAD"), require = 0)
private void lambdynlights$storeLightPos(int x, int y, int z, CallbackInfoReturnable<Integer> cir) {
if (!LambDynLights.get().config.getDynamicLightsMode().isEnabled())
return;

// Store the current light position.
// This is possible under smooth lighting scenarios, because AoFaceData in Sodium runs a get() call
// before getting the lightmap.
SodiumDynamicLightHandler.lambdynlights$pos.get().set(x, y, z);
}
// Store the current light position.
// This is possible under smooth lighting scenarios, because AoFaceData in Sodium runs a get() call
// before getting the lightmap.
SodiumDynamicLightHandler.pos.get().set(x, y, z);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,20 @@
@Pseudo
@Mixin(targets = "me.jellysquid.mods.sodium.client.model.light.flat.FlatLightPipeline", remap = false)
public abstract class FlatLightPipelineMixin {
@Dynamic
@Inject(method = "getOffsetLightmap", at = @At(value = "RETURN", ordinal = 1), remap = false, locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
private void lambdynlights$getLightmap(BlockPos pos, Direction face, CallbackInfoReturnable<Integer> cir, int word, int adjWord) {
int lightmap = SodiumDynamicLightHandler.lambdynlights$getLightmap(pos, adjWord, cir.getReturnValueI());
cir.setReturnValue(lightmap);
}
@Dynamic
@Inject(
method = "getOffsetLightmap",
at = @At(value = "RETURN", ordinal = 1),
require = 0,
remap = false,
locals = LocalCapture.CAPTURE_FAILHARD,
cancellable = true
)
private void lambdynlights$getLightmap(
BlockPos pos, Direction face, CallbackInfoReturnable<Integer> cir,
int word, int adjWord
) {
int lightmap = SodiumDynamicLightHandler.getLightmap(pos, adjWord, cir.getReturnValueI());
cir.setReturnValue(lightmap);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
@Pseudo
@Mixin(targets = "me.jellysquid.mods.sodium.client.model.light.data.LightDataAccess", remap = false)
public abstract class LightDataAccessMixin {
@Dynamic
@Inject(method = "getLightmap", at = @At("RETURN"), remap = false, cancellable = true)
private static void lambdynlights$getLightmap(int word, CallbackInfoReturnable<Integer> cir) {
int lightmap = SodiumDynamicLightHandler.lambdynlights$getLightmap(SodiumDynamicLightHandler.lambdynlights$pos.get(), word, cir.getReturnValueI());
cir.setReturnValue(lightmap);
}
@Dynamic
@Inject(method = "getLightmap", at = @At("RETURN"), remap = false, require = 0, cancellable = true)
private static void lambdynlights$getLightmap(int word, CallbackInfoReturnable<Integer> cir) {
int lightmap = SodiumDynamicLightHandler.getLightmap(SodiumDynamicLightHandler.pos.get(), word, cir.getReturnValueI());
cir.setReturnValue(lightmap);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,25 @@
package dev.lambdaurora.lambdynlights.util;

import dev.lambdaurora.lambdynlights.LambDynLights;
import me.jellysquid.mods.sodium.client.model.light.data.LightDataAccess;
import net.minecraft.util.math.BlockPos;
import org.jetbrains.annotations.ApiStatus;

@ApiStatus.Internal
public interface SodiumDynamicLightHandler {
// Stores the current light position being used by ArrayLightDataCache#get
// We use ThreadLocal because Sodium's chunk builder is multithreaded, otherwise it will break
// catastrophically.
ThreadLocal<BlockPos.Mutable> lambdynlights$pos = ThreadLocal.withInitial(BlockPos.Mutable::new);
// Stores the current light position being used by ArrayLightDataCache#get
// We use ThreadLocal because Sodium's chunk builder is multithreaded, otherwise it will break
// catastrophically.
ThreadLocal<BlockPos.Mutable> pos = ThreadLocal.withInitial(BlockPos.Mutable::new);

static int lambdynlights$getLightmap(BlockPos pos, int word, int lightmap) {
if (!LambDynLights.get().config.getDynamicLightsMode().isEnabled())
return lightmap;
static int getLightmap(BlockPos pos, int word, int lightmap) {
if (!LambDynLights.get().config.getDynamicLightsMode().isEnabled())
return lightmap;

// Equivalent to world.getBlockState(pos).isOpaqueFullCube(world, pos)
if (LightDataAccess.unpackFO(word))
return lightmap;
// Equivalent to world.getBlockState(pos).isOpaqueFullCube(world, pos)
if (/*LightDataAccess.unpackFO(word)*/ (word >>> 30 & 1) != 0)
return lightmap;

double dynamic = LambDynLights.get().getDynamicLightLevel(pos);
return LambDynLights.get().getLightmapWithDynamicLight(dynamic, lightmap);
}
double dynamic = LambDynLights.get().getDynamicLightLevel(pos);
return LambDynLights.get().getLightmapWithDynamicLight(dynamic, lightmap);
}
}
9 changes: 9 additions & 0 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@
"optifabric": "*"
},
"custom": {
"modmenu": {
"links": {
"modmenu.curseforge": "https://www.curseforge.com/minecraft/mc-mods/lambdynamiclights",
"modmenu.discord": "https://discord.lambdaurora.dev/",
"modmenu.github_releases": "https://github.com/LambdAurora/LambDynamicLights/releases",
"modmenu.modrinth": "https://modrinth.com/mod/lambdynamiclights",
"modmenu.twitter": "https://twitter.com/LambdAurora"
}
},
"modupdater": {
"strategy": "curseforge",
"projectID": 393442
Expand Down

0 comments on commit 100de58

Please sign in to comment.