From 68857dfa69104c80cbb2cc76fe7ad9ad5abde5f9 Mon Sep 17 00:00:00 2001 From: toxicity Date: Sun, 5 May 2024 18:18:02 +0900 Subject: [PATCH] Fixes core shader. --- .../manager/PlaceholderManagerImpl.kt | 40 ++++++++++++------- .../shaders/core/rendertype_text.vsh | 7 ++-- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/dist/src/main/kotlin/kr/toxicity/healthbar/manager/PlaceholderManagerImpl.kt b/dist/src/main/kotlin/kr/toxicity/healthbar/manager/PlaceholderManagerImpl.kt index 8c82002..01e24fe 100644 --- a/dist/src/main/kotlin/kr/toxicity/healthbar/manager/PlaceholderManagerImpl.kt +++ b/dist/src/main/kotlin/kr/toxicity/healthbar/manager/PlaceholderManagerImpl.kt @@ -1,5 +1,6 @@ package kr.toxicity.healthbar.manager +import kr.toxicity.healthbar.api.compatibility.MythicActiveMob import kr.toxicity.healthbar.api.healthbar.HealthBarData import kr.toxicity.healthbar.api.manager.PlaceholderManager import kr.toxicity.healthbar.api.placeholder.PlaceholderContainer @@ -11,6 +12,7 @@ import org.bukkit.NamespacedKey import org.bukkit.Registry import org.bukkit.Tag import org.bukkit.attribute.Attribute +import org.bukkit.entity.Player import org.bukkit.potion.PotionEffectType import java.util.function.Function @@ -39,23 +41,31 @@ object PlaceholderManagerImpl: PlaceholderManager, BetterHealthBerManager { e.entity.entity().name } } - PlaceholderContainer.BOOL.addPlaceholder("has_potion_effect", placeholder(1) { - if (MinecraftVersion.current >= MinecraftVersion.version1_20_3) { - Registry.EFFECT.get(NamespacedKey.minecraft(it[0])) - } else { - @Suppress("DEPRECATION") - PotionEffectType.getByName(it[0]) - }?.let { type -> - Function { pair: HealthBarData -> - pair.entity.entity().hasPotionEffect(type) - } - } ?: run { - warn("Unable to find this potion effect: ${it[0]}") - Function { _: HealthBarData -> - false + PlaceholderContainer.BOOL.run { + addPlaceholder("has_potion_effect", placeholder(1) { + if (MinecraftVersion.current >= MinecraftVersion.version1_20_3) { + Registry.EFFECT.get(NamespacedKey.minecraft(it[0])) + } else { + @Suppress("DEPRECATION") + PotionEffectType.getByName(it[0]) + }?.let { type -> + Function { pair: HealthBarData -> + pair.entity.entity().hasPotionEffect(type) + } + } ?: run { + warn("Unable to find this potion effect: ${it[0]}") + Function { _: HealthBarData -> + false + } } + }) + addPlaceholder("is_player") { e: HealthBarData -> + e.entity.entity() is Player + } + addPlaceholder("is_mythic_mob") { e: HealthBarData -> + e.entity.mob() is MythicActiveMob } - }) + } } override fun reload(resource: PackResource) { diff --git a/dist/src/main/resources/pack/assets/minecraft/shaders/core/rendertype_text.vsh b/dist/src/main/resources/pack/assets/minecraft/shaders/core/rendertype_text.vsh index 2b439ff..799c16c 100644 --- a/dist/src/main/resources/pack/assets/minecraft/shaders/core/rendertype_text.vsh +++ b/dist/src/main/resources/pack/assets/minecraft/shaders/core/rendertype_text.vsh @@ -56,17 +56,16 @@ void main() { float alpha = texColor.a; if (alpha < 1) { applyColor = 1; - float applyAlpha = alpha / 100; float pitchAdd = cos(pitch - 3.1415 / 2) * HEIGHT; - float xAlpha = cos(pitch) * applyAlpha; - vec3 alphaVector = vec3(xAlpha * cos(yaw), -sin(pitch) * applyAlpha, xAlpha * sin(yaw)); + float xAlpha = cos(pitch) * alpha; + vec3 alphaVector = vec3(xAlpha * sin(yaw), -sin(pitch) * alpha, -xAlpha * cos(yaw)); pos.y += cos(pitch) * HEIGHT; pos.x += sin(yaw) * pitchAdd; pos.z -= cos(yaw) * pitchAdd; - pos += alphaVector; + pos += alphaVector / 100; } } }