From 94faaad338f884868f92d3b3e74ae0d1f6d16d09 Mon Sep 17 00:00:00 2001 From: Genny Date: Fri, 21 Feb 2020 01:00:43 -0600 Subject: Implement sunlight filtering with black glass --- src/main/java/dev/genbyte/sunfright/Damager.java | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/main/java/dev/genbyte') diff --git a/src/main/java/dev/genbyte/sunfright/Damager.java b/src/main/java/dev/genbyte/sunfright/Damager.java index 42d6133..bfb977f 100644 --- a/src/main/java/dev/genbyte/sunfright/Damager.java +++ b/src/main/java/dev/genbyte/sunfright/Damager.java @@ -4,6 +4,7 @@ import java.util.Collection; import java.util.logging.Level; import org.bukkit.Material; +import org.bukkit.block.Block; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -43,6 +44,13 @@ public class Damager extends BukkitRunnable { public void run() { ItemStack helmet = player.getInventory().getHelmet(); + Block topBlock = player.getWorld().getBlockAt( + player.getWorld().getHighestBlockAt(player.getLocation()).getLocation().subtract(0, 1, 0)); + + if (topBlock.getLocation().getY() > player.getLocation().getY() + && topBlock.getType().equals(Material.BLACK_STAINED_GLASS)) { + return; + } if (helmet != null) { ItemMeta helmetMeta = helmet.getItemMeta(); -- cgit 1.4.1-3-g733a5