package at.hannibal2.skyhanni.utils
import at.hannibal2.skyhanni.config.core.config.Position
import at.hannibal2.skyhanni.data.GuiEditManager
import at.hannibal2.skyhanni.data.GuiEditManager.Companion.getAbsX
import at.hannibal2.skyhanni.data.GuiEditManager.Companion.getAbsY
import at.hannibal2.skyhanni.events.GuiRenderItemEvent
import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent
import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.renderables.Renderable
import at.hannibal2.skyhanni.utils.renderables.RenderableUtils.renderXAligned
import io.github.moulberry.moulconfig.internal.TextRenderUtils
import io.github.moulberry.notenoughupdates.util.Utils
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.FontRenderer
import net.minecraft.client.gui.Gui
import net.minecraft.client.renderer.GlStateManager
import net.minecraft.client.renderer.Tessellator
import net.minecraft.client.renderer.vertex.DefaultVertexFormats
import net.minecraft.enchantment.Enchantment
import net.minecraft.entity.Entity
import net.minecraft.inventory.Slot
import net.minecraft.item.ItemStack
import net.minecraft.util.AxisAlignedBB
import net.minecraft.util.MathHelper
import net.minecraft.util.ResourceLocation
import org.lwjgl.opengl.GL11
import java.awt.Color
import kotlin.math.cos
import kotlin.math.sin
import kotlin.math.sqrt
import kotlin.time.Duration
import kotlin.time.DurationUnit
object RenderUtils {
enum class HorizontalAlignment { LEFT, CENTER, RIGHT }
enum class VerticalAlignment { TOP, CENTER, BOTTOM }
private val beaconBeam = ResourceLocation("textures/entity/beacon_beam.png")
infix fun Slot.highlight(color: LorenzColor) {
highlight(color.toColor())
}
infix fun Slot.highlight(color: Color) {
GlStateManager.color(1f, 1f, 1f, 1f)
GlStateManager.pushAttrib()
GL11.glDisable(GL11.GL_LIGHTING)
GL11.glEnable(GL11.GL_DEPTH_TEST)
GlStateManager.pushMatrix()
// TODO don't use z
GlStateManager.translate(0f, 0f, 110 + Minecraft.getMinecraft().renderItem.zLevel)
Gui.drawRect(
this.xDisplayPosition,
this.yDisplayPosition,
this.xDisplayPosition + 16,
this.yDisplayPosition + 16,
color.rgb
)
GlStateManager.popMatrix()
GlStateManager.popAttrib()
}
fun LorenzRenderWorldEvent.drawColor(
location: LorenzVec,
color: LorenzColor,
beacon: Boolean = false,
alpha: Float = -1f,
) {
drawColor(location, color.toColor(), beacon, alpha)
}
fun LorenzRenderWorldEvent.drawColor(
location: LorenzVec,
color: Color,
beacon: Boolean = false,
alpha: Float = -1f,
) {
val (viewerX, viewerY, viewerZ) = getViewerPos(partialTicks)
val x = location.x - viewerX
val y = location.y - viewerY
val z = location.z - viewerZ
val distSq = x * x + y * y + z * z
val realAlpha = if (alpha == -1f) {
(0.1f + 0.005f * distSq.toFloat()).coerceAtLeast(0.2f)
} else {
alpha
}
GlStateManager.disableD