From 2ba3a2216615720c73416125f79a4e5a3c355cdf Mon Sep 17 00:00:00 2001 From: mczme <126310378+mczme@users.noreply.github.com> Date: Wed, 20 Nov 2024 14:38:17 +0800 Subject: [PATCH] added SodiumDynamicLights(New DynamicLightsReforged ) support --- .../radiantgear/RadiantGearForgeMod.java | 5 +++ .../sodiumdynamiclights/SDLModule.java | 34 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 forge/src/main/java/com/illusivesoulworks/radiantgear/integration/sodiumdynamiclights/SDLModule.java diff --git a/forge/src/main/java/com/illusivesoulworks/radiantgear/RadiantGearForgeMod.java b/forge/src/main/java/com/illusivesoulworks/radiantgear/RadiantGearForgeMod.java index d031acf..4b96bc9 100644 --- a/forge/src/main/java/com/illusivesoulworks/radiantgear/RadiantGearForgeMod.java +++ b/forge/src/main/java/com/illusivesoulworks/radiantgear/RadiantGearForgeMod.java @@ -49,6 +49,7 @@ public RadiantGearForgeMod() { isDLReforgedLoaded = modList.isLoaded("dynamiclightsreforged"); isArsNouveauLoaded = modList.isLoaded("ars_nouveau"); isRyoamicLoaded = modList.isLoaded("ryoamiclights"); + isSodiumDynamicLights = modList.isLoaded("sodiumdynamiclights"); // Embeddium++ removed their dynamic lighting in 1.2.4 but this mod should still be able to load if (modList.isLoaded("embeddiumplus")) { DefaultArtifactVersion maxVersion = new DefaultArtifactVersion("1.2.4"); @@ -90,6 +91,10 @@ private void clientSetup(final FMLClientSetupEvent evt) { if (isArsNouveauLoaded) { ArsNouveauModule.setup(); } + + if (isSodiumDynamicLights) { + SDLModule.setup(); + } } private String getRemoteVersion(ModLoadingContext context) { diff --git a/forge/src/main/java/com/illusivesoulworks/radiantgear/integration/sodiumdynamiclights/SDLModule.java b/forge/src/main/java/com/illusivesoulworks/radiantgear/integration/sodiumdynamiclights/SDLModule.java new file mode 100644 index 0000000..643261a --- /dev/null +++ b/forge/src/main/java/com/illusivesoulworks/radiantgear/integration/sodiumdynamiclights/SDLModule.java @@ -0,0 +1,34 @@ +package com.illusivesoulworks.radiantgear.integration.sodiumdynamiclights; + +import com.illusivesoulworks.radiantgear.client.BaseLambDynLightsModule; +import toni.sodiumdynamiclights.SodiumDynamicLights; +import dev.lambdaurora.lambdynlights.api.DynamicLightHandlers; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.item.ItemStack; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.EntityJoinLevelEvent; + +import java.util.function.Function; + +public class SDLModule extends BaseLambDynLightsModule { + public static void setup() { + SDLModule module = new SDLModule(); + MinecraftForge.EVENT_BUS.addListener(module::entityJoin); + } + + private void entityJoin(final EntityJoinLevelEvent evt) { + this.registerEntity(evt.getEntity(), evt.getLevel()); + } + + @Override + protected int getLuminance(ItemStack stack, boolean isInWater) { + return SodiumDynamicLights.getLuminanceFromItemStack(stack, isInWater); + } + + @Override + protected void registerDynamicLightHandler(EntityType type, + Function handler) { + DynamicLightHandlers.registerDynamicLightHandler(type, handler::apply); + } +}