Skip to content

Commit 2f595a5

Browse files
committed
Merge v3.1.4 changes into 1.21.2.
2 parents 3a40f39 + be6aa16 commit 2f595a5

File tree

8 files changed

+200
-1
lines changed

8 files changed

+200
-1
lines changed

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,10 @@
216216

217217
- Fixed item frames and other "block-attached" entities not ticking properly on the integrated server.
218218

219+
### 3.1.4
220+
221+
- Added support for Trinkets and Accessories.
222+
219223
## 3.2.0
220224

221225
- Updated to Minecraft 1.21.2.
@@ -241,6 +245,11 @@
241245
- Same changes as v3.1.3 but for 1.21.3.
242246
- Fixed item frames and other "block-attached" entities not ticking properly on the integrated server.
243247

248+
### 3.2.4
249+
250+
- Same changes as v3.1.4 but for 1.21.3.
251+
- Added support for Trinkets and Accessories.
252+
244253
[SpruceUI]: https://github.com/LambdAurora/SpruceUI "SpruceUI page"
245254
[pridelib]: https://github.com/Queerbric/pridelib "Pridelib page"
246255
[Sodium]: https://modrinth.com/mod/sodium "Sodium Modrinth page"

build.gradle.kts

+9
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ repositories {
2828
name = "ParchmentMC"
2929
url = uri("https://maven.parchmentmc.org")
3030
}
31+
maven {
32+
name = "Ladysnake Libs"
33+
url = uri("https://maven.ladysnake.org/releases")
34+
}
35+
maven { url = uri("https://maven.wispforest.io/releases") }
3136
}
3237

3338
loom {
@@ -50,6 +55,10 @@ dependencies {
5055
this.isTransitive = false
5156
}
5257

58+
// Mod compatibility
59+
modCompileOnly(libs.trinkets)
60+
modCompileOnly(libs.accessories)
61+
5362
shadow(project(":api", configuration = "namedElements")) {
5463
isTransitive = false
5564
}

build_logic/src/main/kotlin/lambdynamiclights/Constants.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import org.gradle.accessors.dm.LibrariesForLibs
55
object Constants {
66
const val GROUP = "dev.lambdaurora"
77
const val NAME = "lambdynamiclights"
8-
const val VERSION = "3.2.3"
8+
const val VERSION = "3.2.4"
99
const val JAVA_VERSION = 21
1010

1111
private var minecraftVersion: String? = null

gradle/libs.versions.toml

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ yumi-commons = "1.0.0-alpha.1"
1010
spruceui = "6.1.0+1.21.2"
1111
pridelib = "1.3.0+1.21.2"
1212
modmenu = "12.0.0-beta.1"
13+
trinkets = "3.10.0"
14+
accessories = "1.2.1-beta.2+1.21.2"
1315

1416
# Configuration
1517
nightconfig = "3.8.1"
@@ -31,6 +33,8 @@ yumi-commons-event = { module = "dev.yumi.commons:yumi-commons-event", version.r
3133
spruceui = { module = "dev.lambdaurora:spruceui", version.ref = "spruceui" }
3234
pridelib = { module = "io.github.queerbric:pridelib", version.ref = "pridelib" }
3335
modmenu = { module = "com.terraformersmc:modmenu", version.ref = "modmenu" }
36+
trinkets = { module = "dev.emi:trinkets", version.ref = "trinkets" }
37+
accessories = { module = "io.wispforest:accessories-fabric", version.ref = "accessories" }
3438

3539
# Configuration
3640
nightconfig-core = { module = "com.electronwill.night-config:core", version.ref = "nightconfig" }

src/main/java/dev/lambdaurora/lambdynlights/LambDynLights.java

+25
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import dev.lambdaurora.lambdynlights.accessor.WorldRendererAccessor;
1313
import dev.lambdaurora.lambdynlights.api.DynamicLightHandlers;
1414
import dev.lambdaurora.lambdynlights.api.DynamicLightsInitializer;
15+
import dev.lambdaurora.lambdynlights.compat.CompatLayer;
1516
import dev.lambdaurora.lambdynlights.engine.DynamicLightingEngine;
1617
import dev.lambdaurora.lambdynlights.resource.item.ItemLightSources;
1718
import dev.yumi.commons.event.EventManager;
@@ -335,6 +336,20 @@ public static void warn(Logger logger, String msg, Object... args) {
335336
logger.warn(msg, args);
336337
}
337338

339+
/**
340+
* Logs an error message.
341+
*
342+
* @param logger the logger to use
343+
* @param msg the message to log
344+
*/
345+
public static void error(Logger logger, String msg, Object... args) {
346+
if (!FabricLoader.getInstance().isDevelopmentEnvironment()) {
347+
msg = "[LambDynLights] " + msg;
348+
}
349+
350+
logger.error(msg, args);
351+
}
352+
338353
/**
339354
* Schedules a chunk rebuild at the specified chunk position.
340355
*
@@ -411,6 +426,16 @@ public static int getLivingEntityLuminanceFromItems(LivingEntity entity) {
411426
luminance = Math.max(luminance, LambDynLights.getLuminanceFromItemStack(equipped, submergedInFluid));
412427
}
413428

429+
if (luminance < 15) {
430+
for (var compat : CompatLayer.LAYERS) {
431+
luminance = Math.max(luminance, compat.getLivingEntityLuminanceFromItems(entity, submergedInFluid));
432+
433+
if (luminance >= 15) {
434+
break;
435+
}
436+
}
437+
}
438+
414439
return luminance;
415440
}
416441

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright © 2024 LambdAurora <[email protected]>
3+
*
4+
* This file is part of LambDynamicLights.
5+
*
6+
* Licensed under the Lambda License. For more information,
7+
* see the LICENSE file.
8+
*/
9+
10+
package dev.lambdaurora.lambdynlights.compat;
11+
12+
import dev.lambdaurora.lambdynlights.LambDynLights;
13+
import io.wispforest.accessories.api.AccessoriesCapability;
14+
import net.minecraft.world.entity.LivingEntity;
15+
16+
/**
17+
* Represents the Accessories compatibility layer.
18+
*
19+
* @author LambdAurora
20+
* @version 3.1.4
21+
* @since 3.1.4
22+
*/
23+
final class AccessoriesCompat implements CompatLayer {
24+
@Override
25+
public int getLivingEntityLuminanceFromItems(LivingEntity entity, boolean submergedInWater) {
26+
int luminance = 0;
27+
var component = AccessoriesCapability.get(entity);
28+
29+
if (component != null) {
30+
for (var equipped : component.getAllEquipped()) {
31+
if (!equipped.stack().isEmpty()) {
32+
luminance = Math.max(luminance, LambDynLights.getLuminanceFromItemStack(equipped.stack(), submergedInWater));
33+
34+
if (luminance >= 15) {
35+
break;
36+
}
37+
}
38+
}
39+
}
40+
41+
return luminance;
42+
}
43+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Copyright © 2024 LambdAurora <[email protected]>
3+
*
4+
* This file is part of LambDynamicLights.
5+
*
6+
* Licensed under the Lambda License. For more information,
7+
* see the LICENSE file.
8+
*/
9+
10+
package dev.lambdaurora.lambdynlights.compat;
11+
12+
import dev.lambdaurora.lambdynlights.LambDynLights;
13+
import net.fabricmc.loader.api.FabricLoader;
14+
import net.minecraft.world.entity.LivingEntity;
15+
import org.jetbrains.annotations.Range;
16+
import org.slf4j.Logger;
17+
import org.slf4j.LoggerFactory;
18+
19+
import java.util.ArrayList;
20+
import java.util.List;
21+
22+
/**
23+
* Represents a compatibility layer with another mod.
24+
*
25+
* @author LambdAurora
26+
* @version 3.1.4
27+
* @since 3.1.4
28+
*/
29+
public interface CompatLayer {
30+
Logger LOGGER = LoggerFactory.getLogger("LambDynamicLights|CompatLayer");
31+
32+
/**
33+
* Loaded compatibility layers.
34+
*/
35+
List<CompatLayer> LAYERS = initLayers();
36+
37+
/**
38+
* Gets the luminance of a living entity from its equipped items.
39+
*
40+
* @param entity the living entity for which to get the luminance from
41+
* @param submergedInWater {@code true} if the entity is submerged in water, or {@code false} otherwise
42+
* @return the luminance of a living entity from its equipped items
43+
*/
44+
@Range(from = 0, to = 15)
45+
int getLivingEntityLuminanceFromItems(LivingEntity entity, boolean submergedInWater);
46+
47+
private static List<CompatLayer> initLayers() {
48+
var layers = new ArrayList<CompatLayer>();
49+
50+
try {
51+
if (FabricLoader.getInstance().isModLoaded("accessories")) {
52+
layers.add(new AccessoriesCompat());
53+
} else if (FabricLoader.getInstance().isModLoaded("trinkets")) {
54+
layers.add(new TrinketsCompat());
55+
}
56+
} catch (LinkageError e) {
57+
LambDynLights.error(
58+
LOGGER,
59+
"Could not load a compatibility layer: THIS IS VERY WRONG, PLEASE REPORT THIS ERROR TO LAMBDYNAMICLIGHTS' AUTHOR ASAP.",
60+
e
61+
);
62+
}
63+
64+
return layers;
65+
}
66+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright © 2024 LambdAurora <[email protected]>
3+
*
4+
* This file is part of LambDynamicLights.
5+
*
6+
* Licensed under the Lambda License. For more information,
7+
* see the LICENSE file.
8+
*/
9+
10+
package dev.lambdaurora.lambdynlights.compat;
11+
12+
import dev.emi.trinkets.api.TrinketsApi;
13+
import dev.lambdaurora.lambdynlights.LambDynLights;
14+
import net.minecraft.world.entity.LivingEntity;
15+
16+
/**
17+
* Represents the Trinkets compatibility layer.
18+
*
19+
* @author LambdAurora
20+
* @version 3.1.4
21+
* @since 3.1.4
22+
*/
23+
final class TrinketsCompat implements CompatLayer {
24+
@Override
25+
public int getLivingEntityLuminanceFromItems(LivingEntity entity, boolean submergedInWater) {
26+
int luminance = 0;
27+
var component = TrinketsApi.getTrinketComponent(entity);
28+
29+
if (component.isPresent()) {
30+
for (var equipped : component.get().getAllEquipped()) {
31+
if (!equipped.getB().isEmpty()) {
32+
luminance = Math.max(luminance, LambDynLights.getLuminanceFromItemStack(equipped.getB(), submergedInWater));
33+
34+
if (luminance >= 15) {
35+
break;
36+
}
37+
}
38+
}
39+
}
40+
41+
return luminance;
42+
}
43+
}

0 commit comments

Comments
 (0)