generated from JamCoreModding/multi-loader-template-mod
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
17de10d
commit fa80972
Showing
6 changed files
with
84 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...n/src/main/java/io/github/jamalam360/utility_belt/compat/LambDynamicLightsLikeCompat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 { | ||
<T extends LivingEntity> void registerDynamicLightHandler(EntityType<T> type, Function<T, Integer> handler); | ||
|
||
int getLuminanceFromItemStack(@NotNull ItemStack stack, boolean submergedInWater); | ||
|
||
boolean isWaterSensitiveCheckEnabled(); | ||
} | ||
} |
7 changes: 3 additions & 4 deletions
7
common/src/main/java/io/github/jamalam360/utility_belt/util/DynamicTags.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters