diff --git a/common/build.gradle b/common/build.gradle index 6fd96d1..08d374c 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -28,7 +28,6 @@ dependencies { modImplementation(libs.accessories.common) { exclude group: "mezz.jei" } - modImplementation libs.owo.lib.fabric // Dependency of Accessories compileOnly libs.mixin.extras.common annotationProcessor libs.mixin.extras.common diff --git a/common/src/main/java/io/github/jamalam360/utility_belt/compat/LambDynamicLightsLikeCompat.java b/common/src/main/java/io/github/jamalam360/utility_belt/compat/LambDynamicLightsLikeCompat.java new file mode 100644 index 0000000..772ab73 --- /dev/null +++ b/common/src/main/java/io/github/jamalam360/utility_belt/compat/LambDynamicLightsLikeCompat.java @@ -0,0 +1,54 @@ +package io.github.jamalam360.utility_belt.compat; + +import io.github.jamalam360.utility_belt.UtilityBeltInventory; +import io.github.jamalam360.utility_belt.state.StateManager; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import org.jetbrains.annotations.NotNull; + +import java.util.function.Function; + +// LambDynamicLights and RyoamicLights +public class LambDynamicLightsLikeCompat { + public static void init(LambDynamicLightsLike lights) { + lights.registerDynamicLightHandler(EntityType.PLAYER, (player) -> getLuminanceInBelt(player, lights)); + } + + private static int getLuminanceInBelt(Player player, LambDynamicLightsLike lights) { + boolean submerged = isEyeSubmergedInFluid(player, lights); + int luminance = 0; + + StateManager stateManager = StateManager.getStateManager(player); + if (stateManager.hasBelt(player)) { + UtilityBeltInventory inv = stateManager.getInventory(player); + + for (ItemStack stack : inv.items()) { + luminance = Math.max(luminance, lights.getLuminanceFromItemStack(stack, submerged)); + } + } + + return luminance; + } + + // From LambDynLights mod + private static boolean isEyeSubmergedInFluid(LivingEntity entity, LambDynamicLightsLike lights) { + if (!lights.isWaterSensitiveCheckEnabled()) { + return false; + } else { + BlockPos eyePos = BlockPos.containing(entity.getX(), entity.getEyeY(), entity.getZ()); + return !entity.level().getFluidState(eyePos).isEmpty(); + } + } + + public interface LambDynamicLightsLike { + void registerDynamicLightHandler(EntityType type, Function handler); + + int getLuminanceFromItemStack(@NotNull ItemStack stack, boolean submergedInWater); + + boolean isWaterSensitiveCheckEnabled(); + } +} diff --git a/common/src/main/java/io/github/jamalam360/utility_belt/util/DynamicTags.java b/common/src/main/java/io/github/jamalam360/utility_belt/util/DynamicTags.java index cc02eef..f697119 100644 --- a/common/src/main/java/io/github/jamalam360/utility_belt/util/DynamicTags.java +++ b/common/src/main/java/io/github/jamalam360/utility_belt/util/DynamicTags.java @@ -1,24 +1,23 @@ package io.github.jamalam360.utility_belt.util; -import com.google.common.base.Suppliers; import dev.architectury.platform.Platform; import io.github.jamalam360.utility_belt.UtilityBelt; import net.minecraft.resources.ResourceLocation; import java.util.ArrayList; import java.util.List; -import java.util.function.Supplier; public class DynamicTags { private static final String LAMB_DYNAMIC_LIGHTS = "lambdynlights"; + private static final String RYOAMIC_LIGHTS = "ryoamiclights"; private static List extraItems = null; public static List getExtraItemsAllowedInUtilityBelt() { if (extraItems == null) { List list = new ArrayList<>(); - if (Platform.isModLoaded(LAMB_DYNAMIC_LIGHTS)) { - UtilityBelt.LOGGER.info("Registering extra Utility Belt entries for LambDynamicLights compatibility."); + if (Platform.isModLoaded(LAMB_DYNAMIC_LIGHTS) || Platform.isModLoaded(RYOAMIC_LIGHTS)) { + UtilityBelt.LOGGER.info("Registering extra Utility Belt entries for dynamic lights compatibility."); list.add(minecraft("torch")); list.add(minecraft("redstone_torch")); list.add(minecraft("soul_torch")); diff --git a/fabric/src/main/java/io/github/jamalam360/utility_belt/fabric/compat/LambDynamicLightsCompat.java b/fabric/src/main/java/io/github/jamalam360/utility_belt/fabric/compat/LambDynamicLightsCompat.java index 9c168e3..9e4f2f0 100644 --- a/fabric/src/main/java/io/github/jamalam360/utility_belt/fabric/compat/LambDynamicLightsCompat.java +++ b/fabric/src/main/java/io/github/jamalam360/utility_belt/fabric/compat/LambDynamicLightsCompat.java @@ -6,44 +6,33 @@ import dev.lambdaurora.lambdynlights.api.DynamicLightsInitializer; import dev.lambdaurora.lambdynlights.api.item.ItemLightSourceManager; import io.github.jamalam360.utility_belt.UtilityBelt; -import io.github.jamalam360.utility_belt.UtilityBeltInventory; -import io.github.jamalam360.utility_belt.state.StateManager; -import net.minecraft.core.BlockPos; +import io.github.jamalam360.utility_belt.compat.LambDynamicLightsLikeCompat; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; +import org.jetbrains.annotations.NotNull; + +import java.util.function.Function; public class LambDynamicLightsCompat implements DynamicLightsInitializer { @Override public void onInitializeDynamicLights(ItemLightSourceManager manager) { UtilityBelt.LOGGER.info("Initializing LambDynamicLights compat for Utility Belt."); - DynamicLightHandlers.registerDynamicLightHandler(EntityType.PLAYER, DynamicLightHandler.makeHandler(this::getLuminanceInBelt, player -> false)); - } - - private int getLuminanceInBelt(Player player) { - boolean submerged = isEyeSubmergedInFluid(player); - int luminance = 0; - - StateManager stateManager = StateManager.getStateManager(player); - if (stateManager.hasBelt(player)) { - UtilityBeltInventory inv = stateManager.getInventory(player); - - for (ItemStack stack : inv.items()) { - luminance = Math.max(luminance, LambDynLights.getLuminanceFromItemStack(stack, submerged)); + LambDynamicLightsLikeCompat.init(new LambDynamicLightsLikeCompat.LambDynamicLightsLike() { + @Override + public void registerDynamicLightHandler(EntityType type, Function handler) { + DynamicLightHandlers.registerDynamicLightHandler(type, DynamicLightHandler.makeHandler(handler, player -> false)); } - } - return luminance; - } + @Override + public int getLuminanceFromItemStack(@NotNull ItemStack stack, boolean submergedInWater) { + return LambDynLights.getLuminanceFromItemStack(stack, submergedInWater); + } - // From LambDynLights mod - private static boolean isEyeSubmergedInFluid(LivingEntity entity) { - if (!LambDynLights.get().config.getWaterSensitiveCheck().get()) { - return false; - } else { - BlockPos eyePos = BlockPos.containing(entity.getX(), entity.getEyeY(), entity.getZ()); - return !entity.level().getFluidState(eyePos).isEmpty(); - } + @Override + public boolean isWaterSensitiveCheckEnabled() { + return LambDynLights.get().config.getWaterSensitiveCheck().get(); + } + }); } } diff --git a/libs.versions.toml b/libs.versions.toml index 92f3888..1884e8b 100644 --- a/libs.versions.toml +++ b/libs.versions.toml @@ -15,9 +15,9 @@ jamlib = "1.2.1+1.21" # https://modrinth.com/mod/accessories/versions accessories = "1.1.0-beta.11+1.21.1" -# https://modrinth.com/mod/owo/versions +# https://modrinth.com/mod/owo-lib/versions owo-lib-fabric = "0.12.15+1.21" -owo-lib-neoforge = "0.12.15-beta.5+1.21" +owo-lib-neoforge = "0.12.15-beta.7+1.21" # https://github.com/LlamaLad7/MixinExtras/releases mixin-extras = "0.4.1" @@ -28,6 +28,9 @@ modmenu = "11.0.1" # https://modrinth.com/mod/lambdynamiclights/versions lambdynamiclights = "3.1.0+1.21.1" +# https://modrinth.com/mod/ryoamiclights +ryoamic-lights = "0.2.11+mc1.21.1-neoforge" + # https://modrinth.com/mod/sodium/versions sodium = "mc1.21-0.6.0-beta.2-fabric" @@ -58,4 +61,6 @@ modmenu = { module = "maven.modrinth:modmenu", version.ref = "modmenu" } lambdynamiclights = { module = "dev.lambdaurora.lambdynamiclights:lambdynamiclights-runtime", version.ref = "lambdynamiclights" } +ryoamic-lights = { module = "maven.modrinth:ryoamiclights", version.ref = "ryoamic-lights" } + sodium = { module = "maven.modrinth:sodium", version.ref = "sodium" } diff --git a/neoforge/build.gradle b/neoforge/build.gradle index aa91738..8baeb02 100644 --- a/neoforge/build.gradle +++ b/neoforge/build.gradle @@ -34,6 +34,9 @@ dependencies { modImplementation libs.accessories.neoforge modImplementation libs.owo.lib.neoforge // Dependency of Accessories + // Compat + modImplementation libs.ryoamic.lights + forgeRuntimeLibrary "blue.endless:jankson:1.2.3" // Dependency of JamLib forgeRuntimeLibrary "io.wispforest:endec:0.1.5" // Dependency of Accessories