From f0f67f8f8435e49640d5131dd861eebb721f5af8 Mon Sep 17 00:00:00 2001 From: LambdAurora Date: Thu, 17 Aug 2023 18:02:29 +0200 Subject: [PATCH] Clean up stuff. --- CHANGELOG.md | 192 +++++++++--------- gradle.properties | 4 +- .../lambdynlights/LambDynLights.java | 24 ++- .../api/item/ItemLightSource.java | 2 + .../api/item/ItemLightSources.java | 57 +++--- .../mixin/lightsource/LivingEntityMixin.java | 11 +- .../mixin/lightsource/PlayerEntityMixin.java | 16 +- src/main/resources/fabric.mod.json | 2 +- 8 files changed, 160 insertions(+), 148 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a633339..3977131d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,154 +2,158 @@ ## 1.0.0 - - Initial release. - - Added dynamic lighting to the game. +- Initial release. +- Added dynamic lighting to the game. ## 1.1.0 - - Added item frame dynamic lighting. - - Added API. - - Added more options. - - Added entities dynamic lighting toggle. - - Added block entities dynamic lighting toggle. - - Added block entity dynamic lighting. - - Allow dynamic lighting for block entities without block states. - - Should not be used in cases where block states can be used. - - Added compatibility with [Lil Tater Reloaded](https://github.com/Yoghurt4C/LilTaterReloaded). - - Lil taters will light up the area if they hold an item emitting light. - - Fixed light not moving when light source was moving too slow. - - Fixed lighting errors with Sodium. +- Added item frame dynamic lighting. +- Added API. +- Added more options. + - Added entities dynamic lighting toggle. + - Added block entities dynamic lighting toggle. +- Added block entity dynamic lighting. + - Allow dynamic lighting for block entities without block states. + - Should not be used in cases where block states can be used. +- Added compatibility with [Lil Tater Reloaded](https://github.com/Yoghurt4C/LilTaterReloaded). + - Lil taters will light up the area if they hold an item emitting light. +- Fixed light not moving when light source was moving too slow. +- Fixed lighting errors with Sodium. ## 1.2.0 - - Added water-sensitive check for items and light sources. - - Added data item tag `#lambdynlights:water_sensitive` which lists every item which can't light up in the water. - - Added an option to enable/disable the feature - - Updated [SpruceUI] to 1.5.6 to fix latest snapshots issues. - - Added "early/WIP" compatibility with [Canvas Renderer]. - - Added a warning message about performance issues. - - Fixed a crash with [Sodium] rc7 with smooth lighting set to HIGH. +- Added water-sensitive check for items and light sources. + - Added data item tag `#lambdynlights:water_sensitive` which lists every item which can't light up in the water. + - Added an option to enable/disable the feature +- Updated [SpruceUI] to 1.5.6 to fix latest snapshots issues. +- Added "early/WIP" compatibility with [Canvas Renderer]. + - Added a warning message about performance issues. +- Fixed a crash with [Sodium] rc7 with smooth lighting set to HIGH. ### 1.2.1 - - Added TNT dynamic lighting. - - Added lighting options for TNT and Creepers. - - Added luminance value to Fire charge item. - - Updated [SpruceUI] to 1.5.8 - - Fixed player dynamic lighting not getting tracked when changing dimensions. +- Added TNT dynamic lighting. +- Added lighting options for TNT and Creepers. +- Added luminance value to Fire charge item. +- Updated [SpruceUI] to 1.5.8 +- Fixed player dynamic lighting not getting tracked when changing dimensions. ### 1.2.2 - - Changed video options dynamic lighting button to redirect to LambDynamicLights settings. - - Fixed random crash. +- Changed video options dynamic lighting button to redirect to LambDynamicLights settings. +- Fixed random crash. ## 1.3.0 - - Added Simplified Chinese translations. - - Added German translations. - - Added Mexican Spanish translations ([#13](https://github.com/LambdAurora/LambDynamicLights/pull/13)). - - Added Polish translations ([#15](https://github.com/LambdAurora/LambDynamicLights/pull/15)). - - Added Russian translations ([#9](https://github.com/LambdAurora/LambDynamicLights/pull/9)). - - Added spectral arrow as item emitting light ([#17](https://github.com/LambdAurora/LambDynamicLights/pull/17)). - - Added dynamic lighting on glowing entities ([#17](https://github.com/LambdAurora/LambDynamicLights/pull/17)). - - Updated to Minecraft 1.16.2 - - Updated [SpruceUI] to 1.6.2. - - Fixed dynamic lighting update issues at chunk borders ([#12](https://github.com/LambdAurora/LambDynamicLights/issues/12)). - - Fixed water-sensitive items lighting up in water on dedicated servers. ([#3](https://github.com/LambdAurora/LambDynamicLights/issues/3)) - - Added new JSON API to add item luminance and water-sensitivity through resource packs. - - Added `DynamicLightHandler#isWaterSensitive` to make some entities water-sensitive like the blaze. - - Fixed incompatibility with future [Sodium] versions. ([#6](https://github.com/LambdAurora/LambDynamicLights/issues/6)) +- Added Simplified Chinese translations. +- Added German translations. +- Added Mexican Spanish translations ([#13](https://github.com/LambdAurora/LambDynamicLights/pull/13)). +- Added Polish translations ([#15](https://github.com/LambdAurora/LambDynamicLights/pull/15)). +- Added Russian translations ([#9](https://github.com/LambdAurora/LambDynamicLights/pull/9)). +- Added spectral arrow as item emitting light ([#17](https://github.com/LambdAurora/LambDynamicLights/pull/17)). +- Added dynamic lighting on glowing entities ([#17](https://github.com/LambdAurora/LambDynamicLights/pull/17)). +- Updated to Minecraft 1.16.2 +- Updated [SpruceUI] to 1.6.2. +- Fixed dynamic lighting update issues at chunk borders ([#12](https://github.com/LambdAurora/LambDynamicLights/issues/12)). +- Fixed water-sensitive items lighting up in water on dedicated servers. ([#3](https://github.com/LambdAurora/LambDynamicLights/issues/3)) + - Added new JSON API to add item luminance and water-sensitivity through resource packs. + - Added `DynamicLightHandler#isWaterSensitive` to make some entities water-sensitive like the blaze. +- Fixed incompatibility with future [Sodium] versions. ([#6](https://github.com/LambdAurora/LambDynamicLights/issues/6)) ### 1.3.1 - - Fixed entity lighting issue with [Sodium] 0.1.0. ([#23](https://github.com/LambdAurora/LambDynamicLights/issues/23)) +- Fixed entity lighting issue with [Sodium] 0.1.0. ([#23](https://github.com/LambdAurora/LambDynamicLights/issues/23)) ### 1.3.2 - - Added entity lighting capabilities to minecarts. - - Added `DynamicLightsInitializer` and `dynamiclights` entrypoint. - - Added Brazilian Portuguese translations. - - Added Estonian translations. - - Added Hindi translations. - - Added Turkish translations. - - Updated French translations. - - Fixed memory leak in dynamic light source tracking. ([#30](https://github.com/LambdAurora/LambDynamicLights/issues/30)) +- Added entity lighting capabilities to minecarts. +- Added `DynamicLightsInitializer` and `dynamiclights` entrypoint. +- Added Brazilian Portuguese translations. +- Added Estonian translations. +- Added Hindi translations. +- Added Turkish translations. +- Updated French translations. +- Fixed memory leak in dynamic light source tracking. ([#30](https://github.com/LambdAurora/LambDynamicLights/issues/30)) ### 1.3.3 - - Added Italian translations ([#40](https://github.com/LambdAurora/LambDynamicLights/pull/40)). - - Optimized dynamic lighting update methods. - - Fixed crash when leaving world with some minimaps mods. ([#37](https://github.com/LambdAurora/LambDynamicLights/issues/37), [#41](https://github.com/LambdAurora/LambDynamicLights/issues/41)) - - Fixed crash with Immersive Portals ([#39](https://github.com/LambdAurora/LambDynamicLights/issues/39)). - - Updated [SpruceUI], and Fabric API dependencies. +- Added Italian translations ([#40](https://github.com/LambdAurora/LambDynamicLights/pull/40)). +- Optimized dynamic lighting update methods. +- Fixed crash when leaving world with some minimaps mods. ([#37](https://github.com/LambdAurora/LambDynamicLights/issues/37), [#41](https://github.com/LambdAurora/LambDynamicLights/issues/41)) +- Fixed crash with Immersive Portals ([#39](https://github.com/LambdAurora/LambDynamicLights/issues/39)). +- Updated [SpruceUI], and Fabric API dependencies. ### 1.3.4 - - Fix ghost dynamic light source ([#47](https://github.com/LambdAurora/LambDynamicLights/issues/47)). - - Fix missing background in settings screen. - - Updated [SpruceUI]. +- Fix ghost dynamic light source ([#47](https://github.com/LambdAurora/LambDynamicLights/issues/47)). +- Fix missing background in settings screen. +- Updated [SpruceUI]. ## 2.0.0 - - Updated to Minecraft 1.17. - - Updated to Java 16. - - Added dynamic lighting to the Glow Squid. - - And more. +- Updated to Minecraft 1.17. +- Updated to Java 16. +- Added dynamic lighting to the Glow Squid. +- And more. ### 2.0.1 - - Fixed mixin warnings ([#65](https://github.com/LambdAurora/LambDynamicLights/issues/65)). - - Removed any usage of a library. - - Updated [SpruceUI]. +- Fixed mixin warnings ([#65](https://github.com/LambdAurora/LambDynamicLights/issues/65)). +- Removed any usage of a library. +- Updated [SpruceUI]. ### 2.0.2 - - Added Swedish translations ([#68](https://github.com/LambdAurora/LambDynamicLights/pull/68)). - - Block items now respect the `BlockStateTag` in item's NBT ([#71](https://github.com/LambdAurora/LambDynamicLights/issues/71)). - - Fixed glow item frames not emitting light ([#63](https://github.com/LambdAurora/LambDynamicLights/issues/63)). - - Fixed minecart not emitting light when holding a light source ([#70](https://github.com/LambdAurora/LambDynamicLights/issues/70)). - - Fixed glow berries not emitting light ([#72](https://github.com/LambdAurora/LambDynamicLights/issues/72)). - - Fixed glow squids not dimming when attacked ([#75](https://github.com/LambdAurora/LambDynamicLights/issues/75)). - - Fixed LambDynamicLights not rebuilding the correct chunks when at Y -18 or Y -50 ([#76](https://github.com/LambdAurora/LambDynamicLights/issues/76)). +- Added Swedish translations ([#68](https://github.com/LambdAurora/LambDynamicLights/pull/68)). +- Block items now respect the `BlockStateTag` in item's NBT ([#71](https://github.com/LambdAurora/LambDynamicLights/issues/71)). +- Fixed glow item frames not emitting light ([#63](https://github.com/LambdAurora/LambDynamicLights/issues/63)). +- Fixed minecart not emitting light when holding a light source ([#70](https://github.com/LambdAurora/LambDynamicLights/issues/70)). +- Fixed glow berries not emitting light ([#72](https://github.com/LambdAurora/LambDynamicLights/issues/72)). +- Fixed glow squids not dimming when attacked ([#75](https://github.com/LambdAurora/LambDynamicLights/issues/75)). +- Fixed LambDynamicLights not rebuilding the correct chunks when at Y -18 or Y -50 ([#76](https://github.com/LambdAurora/LambDynamicLights/issues/76)). ## 2.1.0 - - Added individual entity toggles ([#64](https://github.com/LambdAurora/LambDynamicLights/issues/64), [#79](https://github.com/LambdAurora/LambDynamicLights/issues/79)). - - Optimized hot methods `maxDynamicLightLevel` and `updateTracking` ([#84](https://github.com/LambdAurora/LambDynamicLights/pull/84)). - - Use `HashSet` for `dynamicLightSources` ([#85](https://github.com/LambdAurora/LambDynamicLights/pull/85)). - - Cache config values for better performances ([#80](https://github.com/LambdAurora/LambDynamicLights/issues/80)). +- Added individual entity toggles ([#64](https://github.com/LambdAurora/LambDynamicLights/issues/64), [#79](https://github.com/LambdAurora/LambDynamicLights/issues/79)). +- Optimized hot methods `maxDynamicLightLevel` and `updateTracking` ([#84](https://github.com/LambdAurora/LambDynamicLights/pull/84)). +- Use `HashSet` for `dynamicLightSources` ([#85](https://github.com/LambdAurora/LambDynamicLights/pull/85)). +- Cache config values for better performances ([#80](https://github.com/LambdAurora/LambDynamicLights/issues/80)). ### 2.1.1 - - Updated to Minecraft 1.19. - - Updated [SpruceUI]. - - Updated [pridelib]. +- Updated to Minecraft 1.19. +- Updated [SpruceUI]. +- Updated [pridelib]. ### 2.1.2 - - Fixed dependencies declaration. +- Fixed dependencies declaration. ## 2.2.0 - - Added option to disable self dynamic lighting. - - Updated Russian translations ([#116](https://github.com/LambdAurora/LambDynamicLights/pull/116), [#121](https://github.com/LambdAurora/LambDynamicLights/pull/121)). - - Added Ukrainian translations ([#120](https://github.com/LambdAurora/LambDynamicLights/pull/120)). +- Added option to disable self dynamic lighting. +- Updated Russian translations ([#116](https://github.com/LambdAurora/LambDynamicLights/pull/116), [#121](https://github.com/LambdAurora/LambDynamicLights/pull/121)). +- Added Ukrainian translations ([#120](https://github.com/LambdAurora/LambDynamicLights/pull/120)). ## 2.3.0 - - Added Traditional Chinese translations ([#142](https://github.com/LambdAurora/LambDynamicLights/pull/142)). - - Updated Brazilian Portuguese translations ([#135](https://github.com/LambdAurora/LambDynamicLights/pull/135)). - - Updated Simplified Chinese translations ([#133](https://github.com/LambdAurora/LambDynamicLights/pull/133)). - - Updated to Minecraft 1.19.4 ([#144](https://github.com/LambdAurora/LambDynamicLights/pull/144)). - - Updated [SpruceUI]. - - Updated [pridelib]. +- Added Traditional Chinese translations ([#142](https://github.com/LambdAurora/LambDynamicLights/pull/142)). +- Updated Brazilian Portuguese translations ([#135](https://github.com/LambdAurora/LambDynamicLights/pull/135)). +- Updated Simplified Chinese translations ([#133](https://github.com/LambdAurora/LambDynamicLights/pull/133)). +- Updated to Minecraft 1.19.4 ([#144](https://github.com/LambdAurora/LambDynamicLights/pull/144)). +- Updated [SpruceUI]. +- Updated [pridelib]. ### 2.3.1 - - Fixed ATLauncher configuration somehow ([#152](https://github.com/LambdAurora/LambDynamicLights/pull/152)). - - Updated to Minecraft 1.20 ([#156](https://github.com/LambdAurora/LambDynamicLights/pull/156)) - - Updated [SpruceUI]. - - Updated night config. +- Fixed ATLauncher configuration somehow ([#152](https://github.com/LambdAurora/LambDynamicLights/pull/152)). +- Updated to Minecraft 1.20 ([#156](https://github.com/LambdAurora/LambDynamicLights/pull/156)) +- Updated [SpruceUI]. +- Updated night config. + +### 2.3.2 + +- Cleaned up some item light source code. [SpruceUI]: https://github.com/LambdAurora/SpruceUI "SpruceUI page" [pridelib]: https://github.com/Queerbric/pridelib "Pridelib page" diff --git a/gradle.properties b/gradle.properties index 1ce89195..4ad13179 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,13 +4,13 @@ org.gradle.jvmargs=-Xmx2G # Fabric Properties # check these on https://fabricmc.net/use minecraft_version=1.20.1 -quilt_mappings=1 +quilt_mappings=23 loader_version=0.14.21 # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api fabric_api_version=0.83.1+1.20.1 # Mod Properties -mod_version = 2.3.1 +mod_version = 2.3.2 maven_group = dev.lambdaurora archives_base_name = lambdynamiclights modrinth_id=yBW8D80W diff --git a/src/main/java/dev/lambdaurora/lambdynlights/LambDynLights.java b/src/main/java/dev/lambdaurora/lambdynlights/LambDynLights.java index 26f8e068..f72350fd 100644 --- a/src/main/java/dev/lambdaurora/lambdynlights/LambDynLights.java +++ b/src/main/java/dev/lambdaurora/lambdynlights/LambDynLights.java @@ -25,6 +25,7 @@ import net.minecraft.client.render.LightmapTextureManager; import net.minecraft.client.render.WorldRenderer; import net.minecraft.entity.Entity; +import net.minecraft.entity.LivingEntity; import net.minecraft.entity.TntEntity; import net.minecraft.entity.mob.CreeperEntity; import net.minecraft.entity.player.PlayerEntity; @@ -48,7 +49,7 @@ * Represents the LambDynamicLights mod. * * @author LambdAurora - * @version 2.1.0 + * @version 2.3.2 * @since 1.0.0 */ public class LambDynLights implements ClientModInitializer { @@ -444,6 +445,27 @@ public static void updateTracking(@NotNull DynamicLightSource lightSource) { } } + private static boolean isEyeSubmergedInFluid(LivingEntity entity) { + if (!LambDynLights.get().config.getWaterSensitiveCheck().get()) { + return false; + } + + var eyePos = BlockPos.create(entity.getX(), entity.getEyeY(), entity.getZ()); + return !entity.getWorld().getFluidState(eyePos).isEmpty(); + } + + public static int getLivingEntityLuminanceFromItems(LivingEntity entity) { + boolean submergedInFluid = isEyeSubmergedInFluid(entity); + int luminance = 0; + + for (var equipped : entity.getItemsEquipped()) { + if (!equipped.isEmpty()) + luminance = Math.max(luminance, LambDynLights.getLuminanceFromItemStack(equipped, submergedInFluid)); + } + + return luminance; + } + /** * Returns the luminance from an item stack. * diff --git a/src/main/java/dev/lambdaurora/lambdynlights/api/item/ItemLightSource.java b/src/main/java/dev/lambdaurora/lambdynlights/api/item/ItemLightSource.java index 88b2178f..8cef8c6d 100644 --- a/src/main/java/dev/lambdaurora/lambdynlights/api/item/ItemLightSource.java +++ b/src/main/java/dev/lambdaurora/lambdynlights/api/item/ItemLightSource.java @@ -163,6 +163,7 @@ public int getLuminance(ItemStack stack) { static int getLuminance(ItemStack stack, BlockState state) { var nbt = stack.getNbt(); + if (nbt != null) { var blockStateTag = nbt.getCompound("BlockStateTag"); var stateManager = state.getBlock().getStateManager(); @@ -175,6 +176,7 @@ static int getLuminance(ItemStack stack, BlockState state) { } } } + return state.getLuminance(); } diff --git a/src/main/java/dev/lambdaurora/lambdynlights/api/item/ItemLightSources.java b/src/main/java/dev/lambdaurora/lambdynlights/api/item/ItemLightSources.java index d5e3a16b..f3b91204 100644 --- a/src/main/java/dev/lambdaurora/lambdynlights/api/item/ItemLightSources.java +++ b/src/main/java/dev/lambdaurora/lambdynlights/api/item/ItemLightSources.java @@ -11,7 +11,9 @@ import com.google.gson.JsonParser; import dev.lambdaurora.lambdynlights.LambDynLights; +import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap; import net.minecraft.item.BlockItem; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.registry.Registries; import net.minecraft.resource.Resource; @@ -20,19 +22,18 @@ import java.io.IOException; import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.List; +import java.util.Map; /** * Represents an item light sources manager. * * @author LambdAurora - * @version 2.1.1 + * @version 2.3.2 * @since 1.3.0 */ public final class ItemLightSources { - private static final List ITEM_LIGHT_SOURCES = new ArrayList<>(); - private static final List STATIC_ITEM_LIGHT_SOURCES = new ArrayList<>(); + private static final Map ITEM_LIGHT_SOURCES = new Reference2ObjectOpenHashMap<>(); + private static final Map STATIC_ITEM_LIGHT_SOURCES = new Reference2ObjectOpenHashMap<>(); private ItemLightSources() { throw new UnsupportedOperationException("ItemLightSources only contains static definitions."); @@ -46,9 +47,10 @@ private ItemLightSources() { public static void load(ResourceManager resourceManager) { ITEM_LIGHT_SOURCES.clear(); - resourceManager.findResources("dynamiclights/item", path -> path.getPath().endsWith(".json")).forEach(ItemLightSources::load); + resourceManager.findResources("dynamiclights/item", path -> path.getPath().endsWith(".json")) + .forEach(ItemLightSources::load); - ITEM_LIGHT_SOURCES.addAll(STATIC_ITEM_LIGHT_SOURCES); + ITEM_LIGHT_SOURCES.putAll(STATIC_ITEM_LIGHT_SOURCES); } private static void load(Identifier resourceId, Resource resource) { @@ -57,7 +59,7 @@ private static void load(Identifier resourceId, Resource resource) { var json = JsonParser.parseReader(reader).getAsJsonObject(); ItemLightSource.fromJson(id, json).ifPresent(data -> { - if (!STATIC_ITEM_LIGHT_SOURCES.contains(data)) + if (!STATIC_ITEM_LIGHT_SOURCES.containsKey(data.item())) register(data); }); } catch (IOException | IllegalStateException e) { @@ -71,15 +73,15 @@ private static void load(Identifier resourceId, Resource resource) { * @param data The item light source data. */ private static void register(ItemLightSource data) { - for (var other : ITEM_LIGHT_SOURCES) { - if (other.item() == data.item()) { - LambDynLights.get().warn("Failed to register item light source \"" + data.id() + "\", duplicates item \"" - + Registries.ITEM.getId(data.item()) + "\" found in \"" + other.id() + "\"."); - return; - } + var other = ITEM_LIGHT_SOURCES.get(data.item()); + + if (other != null) { + LambDynLights.get().warn("Failed to register item light source \"" + data.id() + "\", duplicates item \"" + + Registries.ITEM.getId(data.item()) + "\" found in \"" + other.id() + "\"."); + return; } - ITEM_LIGHT_SOURCES.add(data); + ITEM_LIGHT_SOURCES.put(data.item(), data); } /** @@ -88,15 +90,15 @@ private static void register(ItemLightSource data) { * @param data the item light source data */ public static void registerItemLightSource(ItemLightSource data) { - for (var other : STATIC_ITEM_LIGHT_SOURCES) { - if (other.item() == data.item()) { - LambDynLights.get().warn("Failed to register item light source \"" + data.id() + "\", duplicates item \"" - + Registries.ITEM.getId(data.item()) + "\" found in \"" + other.id() + "\"."); - return; - } + var other = STATIC_ITEM_LIGHT_SOURCES.get(data.item()); + + if (other != null) { + LambDynLights.get().warn("Failed to register item light source \"" + data.id() + "\", duplicates item \"" + + Registries.ITEM.getId(data.item()) + "\" found in \"" + other.id() + "\"."); + return; } - STATIC_ITEM_LIGHT_SOURCES.add(data); + STATIC_ITEM_LIGHT_SOURCES.put(data.item(), data); } /** @@ -107,12 +109,11 @@ public static void registerItemLightSource(ItemLightSource data) { * @return a luminance value */ public static int getLuminance(ItemStack stack, boolean submergedInWater) { - for (var data : ITEM_LIGHT_SOURCES) { - if (data.item() == stack.getItem()) { - return data.getLuminance(stack, submergedInWater); - } - } - if (stack.getItem() instanceof BlockItem blockItem) + var data = ITEM_LIGHT_SOURCES.get(stack.getItem()); + + if (data != null) { + return data.getLuminance(stack, submergedInWater); + } else if (stack.getItem() instanceof BlockItem blockItem) return ItemLightSource.BlockItemLightSource.getLuminance(stack, blockItem.getBlock().getDefaultState()); else return 0; } diff --git a/src/main/java/dev/lambdaurora/lambdynlights/mixin/lightsource/LivingEntityMixin.java b/src/main/java/dev/lambdaurora/lambdynlights/mixin/lightsource/LivingEntityMixin.java index 892f2d43..b6bac72c 100644 --- a/src/main/java/dev/lambdaurora/lambdynlights/mixin/lightsource/LivingEntityMixin.java +++ b/src/main/java/dev/lambdaurora/lambdynlights/mixin/lightsource/LivingEntityMixin.java @@ -15,7 +15,6 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.entity.LivingEntity; -import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; @@ -39,15 +38,7 @@ public void dynamicLightTick() { if (this.isOnFire() || this.isGlowing()) { this.lambdynlights$luminance = 15; } else { - int luminance = 0; - var eyePos = BlockPos.create(this.getX(), this.getEyeY(), this.getZ()); - boolean submergedInFluid = !this.getWorld().getFluidState(eyePos).isEmpty(); - for (var equipped : this.getItemsEquipped()) { - if (!equipped.isEmpty()) - luminance = Math.max(luminance, LambDynLights.getLuminanceFromItemStack(equipped, submergedInFluid)); - } - - this.lambdynlights$luminance = luminance; + this.lambdynlights$luminance = LambDynLights.getLivingEntityLuminanceFromItems((LivingEntity) (Object) this); } int luminance = DynamicLightHandlers.getLuminanceFrom(this); diff --git a/src/main/java/dev/lambdaurora/lambdynlights/mixin/lightsource/PlayerEntityMixin.java b/src/main/java/dev/lambdaurora/lambdynlights/mixin/lightsource/PlayerEntityMixin.java index c23b13b4..f140ad91 100644 --- a/src/main/java/dev/lambdaurora/lambdynlights/mixin/lightsource/PlayerEntityMixin.java +++ b/src/main/java/dev/lambdaurora/lambdynlights/mixin/lightsource/PlayerEntityMixin.java @@ -12,11 +12,9 @@ import dev.lambdaurora.lambdynlights.DynamicLightSource; import dev.lambdaurora.lambdynlights.LambDynLights; import dev.lambdaurora.lambdynlights.api.DynamicLightHandlers; -import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -46,16 +44,10 @@ public void dynamicLightTick() { if (this.isOnFire() || this.isGlowing()) { this.lambdynlights$luminance = 15; } else { - int luminance = DynamicLightHandlers.getLuminanceFrom((Entity) this); - - var eyePos = BlockPos.create(this.getX(), this.getEyeY(), this.getZ()); - boolean submergedInFluid = !this.getWorld().getFluidState(eyePos).isEmpty(); - for (var equipped : this.getItemsEquipped()) { - if (!equipped.isEmpty()) - luminance = Math.max(luminance, LambDynLights.getLuminanceFromItemStack(equipped, submergedInFluid)); - } - - this.lambdynlights$luminance = luminance; + this.lambdynlights$luminance = Math.max( + DynamicLightHandlers.getLuminanceFrom(this), + LambDynLights.getLivingEntityLuminanceFromItems(this) + ); } if (this.isSpectator()) diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index e203c302..b8d0dcb2 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -30,7 +30,7 @@ ], "depends": { "fabricloader": ">=0.14.20", - "fabric": ">=0.83.1+1.20.1", + "fabric": ">=0.83.0+1.20", "minecraft": "~1.20", "spruceui": ">=5.0.0", "java": ">=17"