package tamaized.aov.asm;

import com.mojang.blaze3d.platform.GLX;
import net.minecraft.client.shader.Framebuffer;
import net.minecraft.entity.Entity;
import tamaized.aov.common.capabilities.CapabilityList;
import tamaized.aov.common.capabilities.polymorph.IPolymorphCapability;

public class ASMHooks {

	/**
	 * Injection Point:<br>
	 * {@link net.minecraft.entity.Entity#isImmuneToFire}<br>
	 * [BEFORE] IRETURN
	 */
	public static boolean isImmuneToFire(boolean value, Entity entity) {
		if (value)
			return true;
		IPolymorphCapability cap = CapabilityList.getCap(entity, CapabilityList.POLYMORPH);
		return cap != null && cap.getMorph() == IPolymorphCapability.Morph.FireElemental;
	}

	/**
	 * Injection Point:<br>
	 * {@link net.minecraft.client.shader.Framebuffer#func_216492_b}<br>
	 * [BEFORE] {@link net.minecraft.client.shader.Framebuffer#checkFramebufferComplete}
	 */
	public static void enableStencilBuffer(Framebuffer fbo){
		GLX.glBindRenderbuffer(GLX.GL_RENDERBUFFER, fbo.depthBuffer);
		GLX.glRenderbufferStorage(GLX.GL_RENDERBUFFER, org.lwjgl.opengl.EXTPackedDepthStencil.GL_DEPTH24_STENCIL8_EXT, fbo.framebufferTextureWidth, fbo.framebufferTextureHeight);
		GLX.glFramebufferRenderbuffer(GLX.GL_FRAMEBUFFER, org.lwjgl.opengl.EXTFramebufferObject.GL_DEPTH_ATTACHMENT_EXT, GLX.GL_RENDERBUFFER, fbo.depthBuffer);
		GLX.glFramebufferRenderbuffer(GLX.GL_FRAMEBUFFER, org.lwjgl.opengl.EXTFramebufferObject.GL_STENCIL_ATTACHMENT_EXT, GLX.GL_RENDERBUFFER, fbo.depthBuffer);
	}

}

@@ -873,24 +873,53 @@
 plete%7D%0A%09 */%0A
+%09@SuppressWarnings(%22unused%22)%0A
 %09public stat
@@ -962,18 +962,42 @@
 fer fbo)
+ 
 %7B%0A
+%09%09if (fbo.useDepth) %7B%0A%09
 %09%09GLX.gl
@@ -1050,24 +1050,25 @@
 hBuffer);%0A%09%09
+%09
 GLX.glRender
@@ -1226,16 +1226,17 @@
 eight);%0A
+%09
 %09%09GLX.gl
@@ -1383,16 +1383,17 @@
 fer);%0A%09%09
+%09
 GLX.glFr
@@ -1538,14 +1538,18 @@
 uffer);%0A
+%09%09%7D%0A
 %09%7D%0A%0A%7D%0A

check useDepth you dumbass