Skip to content

Commit 8121943

Browse files
committed
Merge v3.1.2 changes into 1.21.2.
2 parents 9b79807 + bc069a2 commit 8121943

File tree

12 files changed

+67
-60
lines changed

12 files changed

+67
-60
lines changed

CHANGELOG.md

+12
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,12 @@
206206

207207
- Fixed in-world item light source data reload not applying.
208208

209+
### 3.1.2
210+
211+
- Added base light of 8 to allays.
212+
- Fixed dynamic lighting of various projectiles.
213+
- Fixed water-sensitive items lighting up underwater while they shouldn't.
214+
209215
## 3.2.0
210216

211217
- Updated to Minecraft 1.21.2.
@@ -220,6 +226,12 @@
220226
- Same changes as v3.1.1 but for 1.21.3.
221227
- Fixed in-world item light source data reload not applying.
222228

229+
### 3.2.2
230+
231+
- Same changes as v3.1.2 but for 1.21.3.
232+
- Fixed dynamic lighting of various projectiles.
233+
- Fixed water-sensitive items lighting up underwater while they shouldn't.
234+
223235
[SpruceUI]: https://github.com/LambdAurora/SpruceUI "SpruceUI page"
224236
[pridelib]: https://github.com/Queerbric/pridelib "Pridelib page"
225237
[Sodium]: https://modrinth.com/mod/sodium "Sodium Modrinth page"

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.1"
8+
const val VERSION = "3.2.2"
99
const val JAVA_VERSION = 21
1010

1111
private var minecraftVersion: String? = null

gradle/libs.versions.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
minecraft = "1.21.3"
33
fabric-loader = "0.16.7"
44
fabric-api = "0.106.1+1.21.3"
5-
mappings-yalmm = "1"
5+
mappings-yalmm = "2"
66
mappings-parchment = "2024.07.28"
77

88
# Dependencies

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

+6-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Contains constants about LambDynamicLights.
1616
*
1717
* @author LambdAurora
18-
* @version 3.0.1
18+
* @version 3.1.2
1919
* @since 3.0.1
2020
*/
2121
public final class LambDynLightsConstants {
@@ -24,6 +24,11 @@ public final class LambDynLightsConstants {
2424
*/
2525
public static final String NAMESPACE = "lambdynlights";
2626

27+
/**
28+
* The unsupported development mode text.
29+
*/
30+
public static final String DEV_MODE_OVERLAY_TEXT = "[LambDynamicLights Dev Version (Unsupported)]";
31+
2732
/**
2833
* {@return {@code true} if this mod is in development mode, or {@code false} otherwise}
2934
*/

src/main/java/dev/lambdaurora/lambdynlights/api/DynamicLightHandler.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
package dev.lambdaurora.lambdynlights.api;
1111

1212
import dev.lambdaurora.lambdynlights.LambDynLights;
13+
import net.minecraft.world.entity.Entity;
1314
import net.minecraft.world.entity.LivingEntity;
1415
import net.minecraft.world.entity.monster.Creeper;
1516
import org.jetbrains.annotations.NotNull;
@@ -22,7 +23,7 @@
2223
*
2324
* @param <T> The type of the light source.
2425
* @author LambdAurora
25-
* @version 1.3.0
26+
* @version 3.1.2
2627
* @since 1.1.0
2728
*/
2829
public interface DynamicLightHandler<T> {
@@ -52,7 +53,7 @@ default boolean isWaterSensitive(T lightSource) {
5253
* @param <T> The type of the entity.
5354
* @return The completed handler.
5455
*/
55-
static <T extends LivingEntity> @NotNull DynamicLightHandler<T> makeHandler(
56+
static <T extends Entity> @NotNull DynamicLightHandler<T> makeHandler(
5657
Function<T, Integer> luminance, Function<T, Boolean> waterSensitive
5758
) {
5859
return new DynamicLightHandler<>() {

src/main/java/dev/lambdaurora/lambdynlights/api/DynamicLightHandlers.java

+15-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
/**
2222
* @author LambdAurora
23-
* @version 3.2.0
23+
* @version 3.2.2
2424
* @since 1.1.0
2525
*/
2626
public final class DynamicLightHandlers {
@@ -32,7 +32,7 @@ private DynamicLightHandlers() {
3232
* Registers the default handlers.
3333
*/
3434
public static void registerDefaultHandlers() {
35-
registerDynamicLightHandler(EntityType.ALLAY, DynamicLightHandler.makeHandler(blaze -> 8, blaze -> true));
35+
registerDynamicLightHandler(EntityType.ALLAY, allay -> 8);
3636
registerDynamicLightHandler(EntityType.BLAZE, DynamicLightHandler.makeHandler(blaze -> 10, blaze -> true));
3737
registerDynamicLightHandler(EntityType.CREEPER, DynamicLightHandler.makeCreeperEntityHandler(null));
3838
registerDynamicLightHandler(EntityType.ENDERMAN, entity -> {
@@ -42,7 +42,8 @@ public static void registerDefaultHandlers() {
4242
return luminance;
4343
});
4444
registerDynamicLightHandler(EntityType.ITEM,
45-
entity -> LambDynLights.getLuminanceFromItemStack(entity.getItem(), entity.isSubmergedInWater()));
45+
entity -> LambDynLights.getLuminanceFromItemStack(entity.getItem(), entity.isSubmergedInWater())
46+
);
4647
registerDynamicLightHandler(EntityType.ITEM_FRAME, entity -> {
4748
var world = entity.level();
4849
return LambDynLights.getLuminanceFromItemStack(entity.getItem(), !world.getFluidState(entity.getBlockPos()).isEmpty());
@@ -57,6 +58,12 @@ public static void registerDefaultHandlers() {
5758
registerDynamicLightHandler(EntityType.GLOW_SQUID,
5859
entity -> (int) MathHelper.clampedLerp(0.f, 12.f, 1.f - entity.getDarkTicksRemaining() / 10.f)
5960
);
61+
62+
// Fireballs and other similar entities
63+
registerDynamicLightHandler(EntityType.FIREBALL, DynamicLightHandler.makeHandler(ball -> 14, ball -> true));
64+
registerDynamicLightHandler(EntityType.SMALL_FIREBALL, DynamicLightHandler.makeHandler(ball -> 12, ball -> true));
65+
registerDynamicLightHandler(EntityType.DRAGON_FIREBALL, ball -> 14);
66+
registerDynamicLightHandler(EntityType.WITHER_SKULL, ball -> 12);
6067
}
6168

6269
/**
@@ -100,8 +107,12 @@ private static <T> void register(DynamicLightHandlerHolder<T> holder, DynamicLig
100107
* @return {@code true} if the entity can light up, otherwise {@code false}
101108
*/
102109
public static <T extends Entity> boolean canLightUp(T entity) {
103-
if (entity == Minecraft.getInstance().player && !LambDynLights.get().config.getSelfLightSource().get())
110+
if (entity == Minecraft.getInstance().player) {
111+
if (!LambDynLights.get().config.getSelfLightSource().get())
112+
return false;
113+
} else if (!LambDynLights.get().config.getEntitiesLightSource().get()) {
104114
return false;
115+
}
105116

106117
var setting = DynamicLightHandlerHolder.cast(entity.getType()).lambdynlights$getSetting();
107118
return !(setting == null || !setting.get());

src/main/java/dev/lambdaurora/lambdynlights/mixin/DebugScreenOverlayMixin.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
package dev.lambdaurora.lambdynlights.mixin;
1111

1212
import dev.lambdaurora.lambdynlights.LambDynLights;
13+
import dev.lambdaurora.lambdynlights.LambDynLightsConstants;
1314
import dev.lambdaurora.lambdynlights.engine.DynamicLightingEngine;
1415
import net.minecraft.TextFormatting;
1516
import net.minecraft.client.gui.components.DebugScreenOverlay;
@@ -24,7 +25,7 @@
2425
* Adds a debug string for dynamic light sources tracking and updates.
2526
*
2627
* @author LambdAurora
27-
* @version 3.2.0
28+
* @version 3.2.2
2829
* @since 1.3.2
2930
*/
3031
@Mixin(DebugScreenOverlay.class)
@@ -49,5 +50,9 @@ private void onGetLeftText(CallbackInfoReturnable<List<String>> cir) {
4950

5051
builder.append(')');
5152
list.add(builder.toString());
53+
54+
if (LambDynLightsConstants.isDevMode()) {
55+
list.add(TextFormatting.RED + LambDynLightsConstants.DEV_MODE_OVERLAY_TEXT);
56+
}
5257
}
5358
}

src/main/java/dev/lambdaurora/lambdynlights/mixin/DevModeMixin.java

+9-5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
1313
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
14+
import dev.lambdaurora.lambdynlights.LambDynLightsConstants;
1415
import net.minecraft.client.Minecraft;
1516
import net.minecraft.client.gui.GuiGraphics;
1617
import net.minecraft.client.renderer.GameRenderer;
@@ -21,22 +22,25 @@
2122

2223
@Mixin(GameRenderer.class)
2324
public class DevModeMixin {
24-
@Final
2525
@Shadow
26+
@Final
2627
private Minecraft minecraft;
2728

2829
@WrapOperation(
2930
method = "Lnet/minecraft/client/renderer/GameRenderer;render(Lnet/minecraft/client/DeltaTracker;Z)V",
3031
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;flush()V")
3132
)
3233
private void handler(GuiGraphics graphics, Operation<Void> original) {
33-
final String text = "[LambDynamicLights Dev Version (Unsupported)]";
3434
int bottom = this.minecraft.getWindow().getGuiScaledHeight();
3535
int y = bottom - this.minecraft.font.lineHeight;
3636

37-
if (this.minecraft.isGameLoadFinished()) {
38-
graphics.fill(0, y - 4, this.minecraft.font.width(text) + 4, bottom, 0xaa000000);
39-
graphics.drawShadowedText(this.minecraft.font, text, 2, y - 2, 0xff0000);
37+
if (this.minecraft.isGameLoadFinished() && !this.minecraft.getDebugOverlay().showDebugScreen()) {
38+
graphics.fill(
39+
0, y - 4,
40+
this.minecraft.font.width(LambDynLightsConstants.DEV_MODE_OVERLAY_TEXT) + 4, bottom,
41+
0xaa000000
42+
);
43+
graphics.drawShadowedText(this.minecraft.font, LambDynLightsConstants.DEV_MODE_OVERLAY_TEXT, 2, y - 2, 0xff0000);
4044
}
4145
original.call(graphics);
4246
}

src/main/java/dev/lambdaurora/lambdynlights/mixin/lightsource/AbstractHurtingProjectileEntityMixin.java

-39
This file was deleted.

src/main/java/dev/lambdaurora/lambdynlights/resource/item/ItemLightSources.java

+13-4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
* Represents an item light sources manager.
4646
*
4747
* @author LambdAurora
48-
* @version 3.2.1
48+
* @version 3.2.2
4949
* @since 1.3.0
5050
*/
5151
public final class ItemLightSources implements ItemLightSourceManager, IdentifiableResourceReloadListener {
@@ -166,12 +166,21 @@ public Event<Identifier, OnRegister> onRegisterEvent() {
166166
public int getLuminance(ItemStack stack, boolean submergedInWater) {
167167
boolean shouldCareAboutWater = submergedInWater && LambDynLights.get().config.getWaterSensitiveCheck().get();
168168

169-
int luminance = Block.byItem(stack.getItem()).defaultState().getLightEmission();
169+
int luminance = 0;
170+
boolean matchedAny = false;
170171

171172
for (var data : lightSources) {
172-
if (shouldCareAboutWater && data.waterSensitive()) continue;
173+
if (data.predicate().test(stack)) {
174+
matchedAny = true;
173175

174-
luminance = Math.max(luminance, data.getLuminance(stack));
176+
if (shouldCareAboutWater && data.waterSensitive()) continue;
177+
178+
luminance = Math.max(luminance, data.getLuminance(stack));
179+
}
180+
}
181+
182+
if (!matchedAny) {
183+
luminance = Block.byItem(stack.getItem()).defaultState().getLightEmission();
175184
}
176185

177186
return luminance;

src/main/resources/fabric.mod.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"depends": {
3232
"fabricloader": ">=0.16.5",
3333
"fabric-api": ">=0.106.1+1.21.2",
34-
"minecraft": ">=1.21.2",
34+
"minecraft": "~1.21 >=1.21.2-",
3535
"spruceui": ">=6.1.0",
3636
"java": ">=21"
3737
},

src/main/resources/lambdynlights.lightsource.mixins.json

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"package": "dev.lambdaurora.lambdynlights.mixin.lightsource",
44
"compatibilityLevel": "JAVA_21",
55
"client": [
6-
"AbstractHurtingProjectileEntityMixin",
76
"AbstractMinecartEntityMixin",
87
"BlockAttachedEntityMixin",
98
"EntityMixin",

0 commit comments

Comments
 (0)