Skip to content

Commit

Permalink
Fixes core shader.
Browse files Browse the repository at this point in the history
  • Loading branch information
toxicity188 committed May 5, 2024
1 parent 80ce3db commit 68857df
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand Down

0 comments on commit 68857df

Please sign in to comment.