Skip to content

Commit

Permalink
[Dynamic Lights] Add Baubles Support (#595)
Browse files Browse the repository at this point in the history
* [Dynamic Lights] Add Baubles Support

* Add IDynamicLightProducer
  • Loading branch information
Caedis authored Aug 15, 2024
1 parent 66563f4 commit 3a1d1b0
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ dependencies {

// Notfine Deps
compileOnly("thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev")
runtimeOnlyNonPublishable("com.github.GTNewHorizons:Baubles:1.0.4:dev")
devOnlyNonPublishable("com.github.GTNewHorizons:Baubles:1.0.4:dev")
compileOnly("com.github.GTNewHorizons:twilightforest:2.5.16:dev") { transitive = false }
compileOnly(rfg.deobf('curse.maven:witchery-69673:2234410'))
compileOnly("com.github.GTNewHorizons:TinkersConstruct:1.12.0-GTNH:dev") { transitive = false }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.gtnewhorizons.angelica.api;

/**
* To be used for modded items that don't have blocks. Baubles for example.
*/
public interface IDynamicLightProducer {
int getLuminance();
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class ModStatus {
public static boolean isBackhandLoaded;
public static boolean isThaumcraftLoaded;
public static boolean isThaumicHorizonsLoaded;
public static boolean isBaublesLoaded;

public static void preInit(){
isBetterCrashesLoaded = Loader.isModLoaded("bettercrashes");
Expand All @@ -42,6 +43,7 @@ public static void preInit(){
isBackhandLoaded = Loader.isModLoaded("backhand");
isThaumcraftLoaded = Loader.isModLoaded("Thaumcraft");
isThaumicHorizonsLoaded = Loader.isModLoaded("ThaumicHorizons");
isBaublesLoaded = Loader.isModLoaded("Baubles");

if (isHoloInventoryLoaded){
isHoloInventoryLoaded = new DefaultArtifactVersion("2.4.4-GTNH")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.gtnewhorizons.angelica.dynamiclights;

import baubles.common.lib.PlayerHandler;
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
import com.gtnewhorizon.gtnhlib.blockpos.IBlockPos;
import com.gtnewhorizon.gtnhlib.util.CoordinatePacker;
import com.gtnewhorizons.angelica.api.IDynamicLightProducer;
import com.gtnewhorizons.angelica.compat.ModStatus;
import com.gtnewhorizons.angelica.config.AngelicaConfig;
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
Expand All @@ -16,6 +18,7 @@
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
Expand Down Expand Up @@ -335,6 +338,8 @@ public static int getLuminanceFromItemStack(@NotNull ItemStack stack, boolean su
if (block != null) {
return block.getLightValue();
}
} else if (item instanceof IDynamicLightProducer lightProducer){
return lightProducer.getLuminance();
}

if (item == Items.lava_bucket) return Blocks.lava.getLightValue();
Expand Down Expand Up @@ -380,6 +385,18 @@ else if (ModStatus.isBackhandLoaded && living instanceof EntityPlayer player){
}
}

if (ModStatus.isBaublesLoaded && living instanceof EntityPlayer player){
var playerBaubles = PlayerHandler.getPlayerBaubles(player);
if (playerBaubles != null){
for (int i = 0; i < playerBaubles.getSizeInventory(); i++){
var stack = playerBaubles.getStackInSlot(i);
if (stack != null){
luminance = Math.max(luminance, getLuminanceFromItemStack(stack, inWater));
}
}
}
}

return luminance;
}

Expand Down

0 comments on commit 3a1d1b0

Please sign in to comment.