Skip to content

Commit

Permalink
Update to 25w05a.
Browse files Browse the repository at this point in the history
  • Loading branch information
LambdAurora committed Jan 29, 2025
1 parent 5f35b78 commit 5d64e33
Show file tree
Hide file tree
Showing 17 changed files with 238 additions and 29 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,11 @@
- Fixed Upside-down English translations ([#257](https://github.com/LambdAurora/LambDynamicLights/pull/257)).
- Fixed custom dynamic light sources sometimes not updating previously lit chunks.

### 4.0.2
### 4.1.0

- Updated to Minecraft 1.21.5.
- Added dynamic lighting to Firefly particles.
- Added support for entity component predicates.
- Updated Traditional Chinese translations ([#261](https://github.com/LambdAurora/LambDynamicLights/pull/261)).
- Updated Turkish translations ([#263](https://github.com/LambdAurora/LambDynamicLights/pull/263)).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import dev.lambdaurora.lambdynlights.api.item.ItemLightSourceManager;
import dev.lambdaurora.lambdynlights.api.predicate.LightSourceLocationPredicate;
import net.minecraft.advancements.critereon.*;
import net.minecraft.core.component.DataComponentExactPredicate;
import net.minecraft.world.entity.Entity;
import org.jetbrains.annotations.Range;

Expand All @@ -27,7 +28,7 @@
* @param predicate the predicate to select which entities emit the given luminance
* @param luminances the luminance sources
* @author LambdAurora
* @version 4.0.0
* @version 4.1.0
* @since 4.0.0
*/
public record EntityLightSource(EntityPredicate predicate, List<EntityLuminance> luminances) {
Expand Down Expand Up @@ -77,20 +78,28 @@ public record EntityPredicate(
Optional<EntityEquipmentPredicate> equipment,
Optional<EntityPredicate> vehicle,
Optional<EntityPredicate> passenger,
Optional<SlotsPredicate> slots
Optional<SlotsPredicate> slots,
Optional<DataComponentExactPredicate> components
) {
public static final Codec<EntityPredicate> CODEC = Codec.recursive(
"EntityPredicate",
codec -> RecordCodecBuilder.create(
instance -> instance.group(
EntityTypePredicate.CODEC.optionalFieldOf("type").forGetter(EntityPredicate::entityType),
LightSourceLocationPredicate.CODEC.optionalFieldOf("location").forGetter(EntityPredicate::located),
MobEffectsPredicate.CODEC.optionalFieldOf("effects").forGetter(EntityPredicate::effects),
EntityFlagsPredicate.CODEC.optionalFieldOf("flags").forGetter(EntityPredicate::flags),
EntityEquipmentPredicate.CODEC.optionalFieldOf("equipment").forGetter(EntityPredicate::equipment),
EntityTypePredicate.CODEC.optionalFieldOf("type")
.forGetter(EntityPredicate::entityType),
LightSourceLocationPredicate.CODEC.optionalFieldOf("location")
.forGetter(EntityPredicate::located),
MobEffectsPredicate.CODEC.optionalFieldOf("effects")
.forGetter(EntityPredicate::effects),
EntityFlagsPredicate.CODEC.optionalFieldOf("flags")
.forGetter(EntityPredicate::flags),
EntityEquipmentPredicate.CODEC.optionalFieldOf("equipment")
.forGetter(EntityPredicate::equipment),
codec.optionalFieldOf("vehicle").forGetter(EntityPredicate::vehicle),
codec.optionalFieldOf("passenger").forGetter(EntityPredicate::passenger),
SlotsPredicate.CODEC.optionalFieldOf("slots").forGetter(EntityPredicate::slots)
SlotsPredicate.CODEC.optionalFieldOf("slots").forGetter(EntityPredicate::slots),
DataComponentExactPredicate.CODEC.optionalFieldOf("components")
.forGetter(EntityPredicate::components)
)
.apply(instance, EntityPredicate::new)
)
Expand Down Expand Up @@ -120,8 +129,10 @@ public boolean test(Entity entity) {
} else if (this.passenger.isPresent()
&& entity.getPassengers().stream().noneMatch(passenger -> this.passenger.get().test(passenger))) {
return false;
} else if (this.slots.isPresent() && !((SlotsPredicate) this.slots.get()).matches(entity)) {
return false;
} else {
return this.slots.isEmpty() || this.slots.get().matches(entity);
return this.components.isEmpty() || !this.components.get().test(entity);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* which provides the ability to register light sources for entities, and to query their luminance.
*
* @author LambdAurora
* @version 4.0.0
* @version 4.1.0
* @see EntityLightSource
* @since 4.0.0
*/
Expand Down Expand Up @@ -86,7 +86,10 @@ interface RegisterContext {
default void register(@NotNull EntityType<?> entityType, @Range(from = 0, to = 15) int luminance) {
this.register(new EntityLightSource(
new EntityLightSource.EntityPredicate(
Optional.of(EntityTypePredicate.of(this.registryAccess().lookupOrThrow(Registries.ENTITY_TYPE), entityType)),
Optional.of(EntityTypePredicate.of(
this.registryAccess().lookupOrThrow(Registries.ENTITY_TYPE), entityType
)),
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty(),
Expand All @@ -110,7 +113,10 @@ default void register(@NotNull EntityType<?> entityType, @Range(from = 0, to = 1
default void register(@NotNull EntityType<?> entityType, EntityLuminance... luminance) {
this.register(new EntityLightSource(
new EntityLightSource.EntityPredicate(
Optional.of(EntityTypePredicate.of(this.registryAccess().lookupOrThrow(Registries.ENTITY_TYPE), entityType)),
Optional.of(EntityTypePredicate.of(
this.registryAccess().lookupOrThrow(Registries.ENTITY_TYPE), entityType
)),
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* @param includeRain {@code true} if the wetness check should include rain, or {@code false} otherwise
* @param always let the item be always considered dry or wet if present
* @author LambdAurora
* @version 4.0.0
* @version 4.1.0
* @since 4.0.0
*/
public record ItemDerivedEntityLuminance(ItemStack item, boolean includeRain, Optional<Always> always) implements EntityLuminance {
Expand All @@ -53,7 +53,7 @@ public record ItemDerivedEntityLuminance(ItemStack item, boolean includeRain, Op
boolean wet = this.always.map(value -> switch (value) {
case DRY -> false;
case WET -> true;
}).orElseGet(() -> this.includeRain ? entity.isInWaterRainOrBubble() : entity.isSubmergedInWater());
}).orElseGet(() -> this.includeRain ? entity.isInWaterOrRain() : entity.isSubmergedInWater());

return itemLightSourceManager.getLuminance(this.item, wet);
}
Expand Down
2 changes: 1 addition & 1 deletion build_logic/src/main/kotlin/lambdynamiclights.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ val generateFmj = tasks.register("generateFmj", GenerateFmjTask::class) {
.withIcon("assets/${Constants.NAMESPACE}/icon.png")
.withEnvironment("client")
.withDepend("fabricloader", ">=${libs.versions.fabric.loader.get()}")
.withDepend("minecraft", "~1.21.4-")
.withDepend("minecraft", "~1.21.5-")
.withDepend("java", ">=${Constants.JAVA_VERSION}")
.withModMenu {
it.withLink("modmenu.curseforge", "https://www.curseforge.com/minecraft/mc-mods/lambdynamiclights")
Expand Down
2 changes: 1 addition & 1 deletion build_logic/src/main/kotlin/lambdynamiclights/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ object Constants {
const val NAME = "lambdynamiclights"
const val NAMESPACE = "lambdynlights"
const val PRETTY_NAME = "LambDynamicLights"
const val VERSION = "4.0.2"
const val VERSION = "4.1.0-alpha.1"
const val JAVA_VERSION = 21

const val DESCRIPTION = "The most feature-complete dynamic lighting mod for Fabric."
Expand Down
12 changes: 6 additions & 6 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[versions]
minecraft = "1.21.4"
fabric-loader = "0.16.9"
fabric-api = "0.110.5+1.21.4"
mappings-yalmm = "9"
minecraft = "25w05a"
fabric-loader = "0.16.10"
fabric-api = "0.115.1+1.21.5"
mappings-yalmm = "1"
mappings-parchment = "2024.07.28"

# Dependencies
yumi-commons = "1.0.0-alpha.2"
spruceui = "6.2.0+1.21.3"
pridelib = "1.3.0+1.21.2"
modmenu = "12.0.0-beta.1"
modmenu = "13.0.1"
trinkets = "3.10.0"
accessories = "1.2.1-beta.2+1.21.2"
accessories = "1.2.15-beta+1.21.4"

# Configuration
nightconfig = "3.8.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* Represents the mod configuration.
*
* @author LambdAurora
* @version 4.0.0
* @version 4.1.0
* @since 1.0.0
*/
public class DynamicLightsConfig {
Expand All @@ -53,6 +53,7 @@ public class DynamicLightsConfig {
private final BooleanSettingEntry selfLightSource;
private final BooleanSettingEntry waterSensitiveCheck;
private final BooleanSettingEntry beamLighting;
private final BooleanSettingEntry fireflyLighting;
private final BooleanSettingEntry guardianLaser;
private final BooleanSettingEntry debugActiveDynamicLightingCells;
private final BooleanSettingEntry debugDisplayDynamicLightingChunkRebuild;
Expand Down Expand Up @@ -94,6 +95,10 @@ public DynamicLightsConfig(@NotNull LambDynLights mod) {
"light_sources.beam", true, this.config,
Text.translatable("lambdynlights.option.light_sources.beam.tooltip")
);
this.fireflyLighting = new BooleanSettingEntry(
"light_sources.firefly", true, this.config,
Text.translatable("lambdynlights.option.light_sources.firefly.tooltip")
);
this.guardianLaser = new BooleanSettingEntry(
"light_sources.guardian_laser", true, this.config,
Text.translatable("lambdynlights.option.light_sources.guardian_laser.tooltip")
Expand All @@ -116,6 +121,7 @@ public DynamicLightsConfig(@NotNull LambDynLights mod) {
this.selfLightSource,
this.waterSensitiveCheck,
this.beamLighting,
this.fireflyLighting,
this.guardianLaser,
this.debugActiveDynamicLightingCells,
this.debugDisplayDynamicLightingChunkRebuild,
Expand Down Expand Up @@ -260,6 +266,13 @@ public BooleanSettingEntry getBeamLighting() {
return this.beamLighting;
}

/**
* {@return the firefly light source setting holder}
*/
public BooleanSettingEntry getFireflyLighting() {
return this.fireflyLighting;
}

/**
* {@return the guardian laser light source setting holder}
*/
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/dev/lambdaurora/lambdynlights/LambDynLights.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import net.minecraft.resources.io.ResourceType;
import net.minecraft.util.profiling.Profiler;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.BlockAndTintGetter;
Expand All @@ -68,7 +69,7 @@
* Represents the LambDynamicLights mod.
*
* @author LambdAurora
* @version 4.0.1
* @version 4.1.0
* @since 1.0.0
*/
@ApiStatus.Internal
Expand Down Expand Up @@ -509,9 +510,12 @@ public static int getLivingEntityLuminanceFromItems(LivingEntity entity) {
boolean submergedInFluid = isEyeSubmergedInFluid(entity);
int luminance = 0;

for (var equipped : entity.getAllSlots()) {
if (!equipped.isEmpty())
for (var equipmentSlot : EquipmentSlot.VALUES) {
var equipped = entity.getItemBySlot(equipmentSlot);

if (!equipped.isEmpty()) {
luminance = Math.max(luminance, INSTANCE.itemLightSources.getLuminance(equipped, submergedInFluid));
}
}

if (luminance < 15) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ private void buildGeneralTab(TabContext context) {
list.addSingleOptionEntry(this.waterSensitiveOption);
list.addSingleOptionEntry(new SpruceSeparatorOption(SPECIAL_DYNAMIC_LIGHT_SOURCES_KEY, true, null));
list.addOptionEntry(this.creeperLightingOption, this.tntLightingOption);
list.addOptionEntry(this.config.getBeamLighting().getOption(), this.config.getGuardianLaser().getOption());
list.addOptionEntry(this.config.getBeamLighting().getOption(), this.config.getFireflyLighting().getOption());
list.addSmallSingleOptionEntry(this.config.getGuardianLaser().getOption());
context.addInnerWidget(list);
}

Expand Down
Loading

0 comments on commit 5d64e33

Please sign in to comment.