<commit_before>package tamaized.aov.client.gui;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.gui.inventory.GuiInventory;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.client.event.EntityViewRenderEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import org.lwjgl.opengl.GL11;
import tamaized.aov.AoV;
import tamaized.aov.client.ClientHelpers;
import tamaized.aov.client.handler.ClientTicker;
import tamaized.aov.common.capabilities.CapabilityList;
import tamaized.aov.common.capabilities.aov.IAoVCapability;
import tamaized.aov.common.capabilities.astro.IAstroCapability;
import tamaized.aov.common.capabilities.polymorph.IPolymorphCapability;
import tamaized.aov.common.config.ConfigHandler;
import tamaized.aov.common.core.abilities.Ability;
import tamaized.aov.common.core.skills.AoVSkills;
import tamaized.aov.common.entity.EntityEarthquake;
import tamaized.aov.proxy.ClientProxy;
import tamaized.tammodized.common.helper.CapabilityHelper;

import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Random;

public class AoVOverlay extends Gui {

	public static final ResourceLocation TEXTURE_ASTRO = new ResourceLocation(AoV.modid, "textures/gui/astro.png");
	public static final ResourceLocation TEXTURE_FOCUS = new ResourceLocation(AoV.modid, "textures/gui/focus.png");
	public static final ResourceLocation TEXTURE_DOGGO = new ResourceLocation(AoV.modid, "textures/gui/doggo.png");
	private static final ResourceLocation TEXTURE_ELEMENTALS = new ResourceLocation(AoV.modid, "textures/entity/fluid.png");
	private static final ResourceLocation TEXTURE_DANGERBIOME = new ResourceLocation(AoV.modid, "textures/gui/dangerbiome.png");
	private static final Minecraft mc = Minecraft.getMinecraft();
	private static final Random rand = new Random();
	public static boolean hackyshit = false;
	public static float intensity = 0F;
	private static EntityLivingBase cacheEntity;
	private static int cacheEntityID = -1;

	@SubscribeEvent
	public void renderOverlayPre(RenderGameOverlayEvent.Pre e) {
		if (e.getType() == RenderGameOverlayEvent.ElementType.HOTBAR) {
			IPolymorphCapability poly = CapabilityHelper.getCap(mc.player, CapabilityList.POLYMORPH, null);
			if (poly != null) {
				if (poly.getMorph() == IPolymorphCapability.Morph.Wolf) {
					e.setCanceled(true);
					float perc = poly.getAttackCooldown() / poly.getInitalAttackCooldown();
					if (perc > 0F) {
						GlStateManager.pushMatrix();
						{
							Tessellator tessellator = Tessellator.getInstance();
							BufferBuilder buffer = tessellator.getBuffer();
							buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
							ScaledResolution resolution = e.getResolution();
							float scale = 3F;
							float w = 89F / scale;
							float h = 54F / scale;
							float x = (float) (resolution.getScaledWidth_double() / 2F) - (w / 2F);
							float y = (float) (resolution.getScaledHeight_double() - 12F) - (h / 2F);
							float alpha = 0.35F;
							float tone = 0.75F;
							float heightscale = perc * h;
							buffer.pos(x, y + heightscale, 0F).tex(0, perc).color(tone, tone, tone, alpha).endVertex();
							buffer.pos(x, y + h, 0F).tex(0, 1).color(tone, tone, tone, alpha).endVertex();
							buffer.pos(x + w, y + h, 0F).tex(1, 1).color(tone, tone, tone, alpha).endVertex();
							buffer.pos(x + w, y + heightscale, 0F).tex(1, perc).color(tone, tone, tone, alpha).endVertex();
							mc.renderEngine.bindTexture(TEXTURE_DOGGO);
							tessellator.draw();
						}
						GlStateManager.popMatrix();
					}
				}
			}
		} else if (e.getType() == RenderGameOverlayEvent.ElementType.AIR) {
			IPolymorphCapability poly = CapabilityHelper.getCap(mc.player, CapabilityList.POLYMORPH, null);
			if (poly != null && poly.getMorph() == IPolymorphCapability.Morph.WaterElemental)
				e.setCanceled(true);
		} else if (e.getType() == RenderGameOverlayEvent.ElementType.ALL) {
			IPolymorphCapability poly = CapabilityHelper.getCap(mc.player, CapabilityList.POLYMORPH, null);
			if (poly != null) {
				ClientTicker.dangerBiomeTicksFlag = (poly.getFlagBits() & 0b0001) == 0b0001;
				if (ClientTicker.dangerBiomeTicks > 0) {
					mc.renderEngine.bindTexture(TEXTURE_DANGERBIOME);
					boolean isWater = (poly.getFlagBits() & 0b0010) == 0b0000;
					float r = isWater ? 1F : 0F;
					float g = isWater ? 0.15F : 0.6F;
					float b = isWater ? 0F : 1F;
					float a = MathHelper.clamp(((float) ClientTicker.dangerBiomeTicks + e.getPartialTicks()) / (float) ClientTicker.dangerBiomeMaxTick, 0F, 1F);
					ScaledResolution resolution = new ScaledResolution(mc);
					Tessellator tessellator = Tessellator.getInstance();
					BufferBuilder buffer = tessellator.getBuffer();
					buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
					buffer.pos(0, resolution.getScaledHeight(), 0).tex(0, 1).color(r, g, b, a).endVertex();
					buffer.pos(resolution.getScaledWidth(), resolution.getScaledHeight(), 0).tex(1, 1).color(r, g, b, a).endVertex();
					buffer.pos(resolution.getScaledWidth(), 0, 0).tex(1, 0).color(r, g, b, a).endVertex();
					buffer.pos(0, 0, 0).tex(0, 0).color(r, g, b, a).endVertex();
					GlStateManager.enableBlend();
					tessellator.draw();
					GlStateManager.disableBlend();
				}
			}
		}
	}

	@SubscribeEvent
	public void renderOverlayPost(RenderGameOverlayEvent.Post e) {
		if (e.getType() != RenderGameOverlayEvent.ElementType.EXPERIENCE) // TODO: ??? shouldnt this be hotbar? recheck it later.
			return;
		ClientTicker.update();
		IAoVCapability cap = CapabilityHelper.getCap(mc.player, CapabilityList.AOV, null);
		FontRenderer fontRender = mc.fontRenderer;
		ScaledResolution sr = new ScaledResolution(mc);
		int sW = sr.getScaledWidth() / 2;

		if (cap != null && cap.hasCoreSkill()) {
			if (ClientProxy.barToggle) {
				GlStateManager.pushMatrix();
				{
					if (ConfigHandler.renderBarOverHotbar)
						GlStateManager.translate(0, sr.getScaledHeight() - 23, 0);
					for (int i = 0; i < 9; i++) {
						int x = sW - 90 + (20 * i);
						int y = ConfigHandler.renderBarOverHotbar || ConfigHandler.renderChargesAboveSpellbar ? 1 - ClientTicker.charges.getValue(i) : 1 + ClientTicker.charges.getValue(i);
						renderCharges(x + ConfigHandler.elementPositions.spellbar_x, y + ConfigHandler.elementPositions.spellbar_y, fontRender, cap, i);
					}
				}
				GlStateManager.popMatrix();
			}

			AoVUIBar.render(this, ConfigHandler.elementPositions.spellbar_x, ConfigHandler.elementPositions.spellbar_y);
			if (cap.getCoreSkill() == AoVSkills.astro_core_1)
				renderAstro(mc.player, sr);
			Entity target = ClientProxy.getTarget() != null ? ClientProxy.getTarget() : ClientHelpers.getTargetOverMouse(mc, 128);
			if (ConfigHandler.renderTarget && target instanceof EntityLivingBase)
				renderTarget((EntityLivingBase) target);
		}
	}

	@SubscribeEvent
	public void render(TickEvent.RenderTickEvent e) {
		if (ConfigHandler.earthquake.shake && e.phase == TickEvent.Phase.START && mc.world != null) {
			for (Entity entity : mc.world.loadedEntityList) {
				if (entity instanceof EntityEarthquake) {
					float intense = (float) (1F - entity.getDistanceSq(Minecraft.getMinecraft().player) / Math.pow(16, 2));
					if (intense > AoVOverlay.intensity)
						AoVOverlay.intensity = intense;
				}
			}
		}
		if (e.phase == TickEvent.Phase.END && mc.currentScreen != null) {
			renderStencils();
		}
		hackyshit = false;
	}

	@SubscribeEvent
	public void render(RenderWorldLastEvent e) {
		renderStencils();
		hackyshit = true;
	}

	@SubscribeEvent
	public void camera(EntityViewRenderEvent.CameraSetup e) {
		if (ConfigHandler.earthquake.shake && intensity > 0) {
			e.setYaw(e.getYaw() + (rand.nextFloat() * 2F - 1F) * intensity);
			e.setPitch(e.getPitch() + (rand.nextFloat() * 2F - 1F) * intensity);
			e.setRoll(e.getRoll() + (rand.nextFloat() * 2F - 1F) * intensity);
			intensity = 0F;
		}
	}

	private void renderStencils() {
		if (mc.world != null) {
			Minecraft.getMinecraft().renderEngine.bindTexture(TEXTURE_ELEMENTALS);
			Tessellator tess = Tessellator.getInstance();
			BufferBuilder buffer = tess.getBuffer();
			ScaledResolution resolution = new ScaledResolution(mc);
			float w = resolution.getScaledWidth();
			float h = resolution.getScaledHeight();
			float scale = 32F;
			float u = 1F / (scale / w);
			float v = 1F / (scale / h);
			Minecraft.getMinecraft().entityRenderer.setupOverlayRendering();
			//			GlStateManager.disableLighting();
			GlStateManager.enableBlend();
			GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
			GlStateManager.shadeModel(GL11.GL_SMOOTH);<commit_msg>dont shake the screen while paused<commit_after>package tamaized.aov.client.gui;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.gui.inventory.GuiInventory;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.client.event.EntityViewRenderEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import org.lwjgl.opengl.GL11;
import tamaized.aov.AoV;
import tamaized.aov.client.ClientHelpers;
import tamaized.aov.client.handler.ClientTicker;
import tamaized.aov.common.capabilities.CapabilityList;
import tamaized.aov.common.capabilities.aov.IAoVCapability;
import tamaized.aov.common.capabilities.astro.IAstroCapability;
import tamaized.aov.common.capabilities.polymorph.IPolymorphCapability;
import tamaized.aov.common.config.ConfigHandler;
import tamaized.aov.common.core.abilities.Ability;
import tamaized.aov.common.core.skills.AoVSkills;
import tamaized.aov.common.entity.EntityEarthquake;
import tamaized.aov.proxy.ClientProxy;
import tamaized.tammodized.common.helper.CapabilityHelper;

import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Random;

public class AoVOverlay extends Gui {

	public static final ResourceLocation TEXTURE_ASTRO = new ResourceLocation(AoV.modid, "textures/gui/astro.png");
	public static final ResourceLocation TEXTURE_FOCUS = new ResourceLocation(AoV.modid, "textures/gui/focus.png");
	public static final ResourceLocation TEXTURE_DOGGO = new ResourceLocation(AoV.modid, "textures/gui/doggo.png");
	private static final ResourceLocation TEXTURE_ELEMENTALS = new ResourceLocation(AoV.modid, "textures/entity/fluid.png");
	private static final ResourceLocation TEXTURE_DANGERBIOME = new ResourceLocation(AoV.modid, "textures/gui/dangerbiome.png");
	private static final Minecraft mc = Minecraft.getMinecraft();
	private static final Random rand = new Random();
	public static boolean hackyshit = false;
	public static float intensity = 0F;
	private static EntityLivingBase cacheEntity;
	private static int cacheEntityID = -1;

	@SubscribeEvent
	public void renderOverlayPre(RenderGameOverlayEvent.Pre e) {
		if (e.getType() == RenderGameOverlayEvent.ElementType.HOTBAR) {
			IPolymorphCapability poly = CapabilityHelper.getCap(mc.player, CapabilityList.POLYMORPH, null);
			if (poly != null) {
				if (poly.getMorph() == IPolymorphCapability.Morph.Wolf) {
					e.setCanceled(true);
					float perc = poly.getAttackCooldown() / poly.getInitalAttackCooldown();
					if (perc > 0F) {
						GlStateManager.pushMatrix();
						{
							Tessellator tessellator = Tessellator.getInstance();
							BufferBuilder buffer = tessellator.getBuffer();
							buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
							ScaledResolution resolution = e.getResolution();
							float scale = 3F;
							float w = 89F / scale;
							float h = 54F / scale;
							float x = (float) (resolution.getScaledWidth_double() / 2F) - (w / 2F);
							float y = (float) (resolution.getScaledHeight_double() - 12F) - (h / 2F);
							float alpha = 0.35F;
							float tone = 0.75F;
							float heightscale = perc * h;
							buffer.pos(x, y + heightscale, 0F).tex(0, perc).color(tone, tone, tone, alpha).endVertex();
							buffer.pos(x, y + h, 0F).tex(0, 1).color(tone, tone, tone, alpha).endVertex();
							buffer.pos(x + w, y + h, 0F).tex(1, 1).color(tone, tone, tone, alpha).endVertex();
							buffer.pos(x + w, y + heightscale, 0F).tex(1, perc).color(tone, tone, tone, alpha).endVertex();
							mc.renderEngine.bindTexture(TEXTURE_DOGGO);
							tessellator.draw();
						}
						GlStateManager.popMatrix();
					}
				}
			}
		} else if (e.getType() == RenderGameOverlayEvent.ElementType.AIR) {
			IPolymorphCapability poly = CapabilityHelper.getCap(mc.player, CapabilityList.POLYMORPH, null);
			if (poly != null && poly.getMorph() == IPolymorphCapability.Morph.WaterElemental)
				e.setCanceled(true);
		} else if (e.getType() == RenderGameOverlayEvent.ElementType.ALL) {
			IPolymorphCapability poly = CapabilityHelper.getCap(mc.player, CapabilityList.POLYMORPH, null);
			if (poly != null) {
				ClientTicker.dangerBiomeTicksFlag = (poly.getFlagBits() & 0b0001) == 0b0001;
				if (ClientTicker.dangerBiomeTicks > 0) {
					mc.renderEngine.bindTexture(TEXTURE_DANGERBIOME);
					boolean isWater = (poly.getFlagBits() & 0b0010) == 0b0000;
					float r = isWater ? 1F : 0F;
					float g = isWater ? 0.15F : 0.6F;
					float b = isWater ? 0F : 1F;
					float a = MathHelper.clamp(((float) ClientTicker.dangerBiomeTicks + e.getPartialTicks()) / (float) ClientTicker.dangerBiomeMaxTick, 0F, 1F);
					ScaledResolution resolution = new ScaledResolution(mc);
					Tessellator tessellator = Tessellator.getInstance();
					BufferBuilder buffer = tessellator.getBuffer();
					buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
					buffer.pos(0, resolution.getScaledHeight(), 0).tex(0, 1).color(r, g, b, a).endVertex();
					buffer.pos(resolution.getScaledWidth(), resolution.getScaledHeight(), 0).tex(1, 1).color(r, g, b, a).endVertex();
					buffer.pos(resolution.getScaledWidth(), 0, 0).tex(1, 0).color(r, g, b, a).endVertex();
					buffer.pos(0, 0, 0).tex(0, 0).color(r, g, b, a).endVertex();
					GlStateManager.enableBlend();
					tessellator.draw();
					GlStateManager.disableBlend();
				}
			}
		}
	}

	@SubscribeEvent
	public void renderOverlayPost(RenderGameOverlayEvent.Post e) {
		if (e.getType() != RenderGameOverlayEvent.ElementType.EXPERIENCE) // TODO: ??? shouldnt this be hotbar? recheck it later.
			return;
		ClientTicker.update();
		IAoVCapability cap = CapabilityHelper.getCap(mc.player, CapabilityList.AOV, null);
		FontRenderer fontRender = mc.fontRenderer;
		ScaledResolution sr = new ScaledResolution(mc);
		int sW = sr.getScaledWidth() / 2;

		if (cap != null && cap.hasCoreSkill()) {
			if (ClientProxy.barToggle) {
				GlStateManager.pushMatrix();
				{
					if (ConfigHandler.renderBarOverHotbar)
						GlStateManager.translate(0, sr.getScaledHeight() - 23, 0);
					for (int i = 0; i < 9; i++) {
						int x = sW - 90 + (20 * i);
						int y = ConfigHandler.renderBarOverHotbar || ConfigHandler.renderChargesAboveSpellbar ? 1 - ClientTicker.charges.getValue(i) : 1 + ClientTicker.charges.getValue(i);
						renderCharges(x + ConfigHandler.elementPositions.spellbar_x, y + ConfigHandler.elementPositions.spellbar_y, fontRender, cap, i);
					}
				}
				GlStateManager.popMatrix();
			}

			AoVUIBar.render(this, ConfigHandler.elementPositions.spellbar_x, ConfigHandler.elementPositions.spellbar_y);
			if (cap.getCoreSkill() == AoVSkills.astro_core_1)
				renderAstro(mc.player, sr);
			Entity target = ClientProxy.getTarget() != null ? ClientProxy.getTarget() : ClientHelpers.getTargetOverMouse(mc, 128);
			if (ConfigHandler.renderTarget && target instanceof EntityLivingBase)
				renderTarget((EntityLivingBase) target);
		}
	}

	@SubscribeEvent
	public void render(TickEvent.RenderTickEvent e) {
		if (ConfigHandler.earthquake.shake && e.phase == TickEvent.Phase.START && mc.world != null) {
			for (Entity entity : mc.world.loadedEntityList) {
				if (entity instanceof EntityEarthquake) {
					float intense = (float) (1F - entity.getDistanceSq(Minecraft.getMinecraft().player) / Math.pow(16, 2));
					if (intense > AoVOverlay.intensity)
						AoVOverlay.intensity = intense;
				}
			}
		}
		if (e.phase == TickEvent.Phase.END && mc.currentScreen != null) {
			renderStencils();
		}
		hackyshit = false;
	}

	@SubscribeEvent
	public void render(RenderWorldLastEvent e) {
		renderStencils();
		hackyshit = true;
	}

	@SubscribeEvent
	public void camera(EntityViewRenderEvent.CameraSetup e) {
		if (!mc.isGamePaused() && ConfigHandler.earthquake.shake && intensity > 0) {
			e.setYaw(e.getYaw() + (rand.nextFloat() * 2F - 1F) * intensity);
			e.setPitch(e.getPitch() + (rand.nextFloat() * 2F - 1F) * intensity);
			e.setRoll(e.getRoll() + (rand.nextFloat() * 2F - 1F) * intensity);
			intensity = 0F;
		}
	}

	private void renderStencils() {
		if (mc.world != null) {
			Minecraft.getMinecraft().renderEngine.bindTexture(TEXTURE_ELEMENTALS);
			Tessellator tess = Tessellator.getInstance();
			BufferBuilder buffer = tess.getBuffer();
			ScaledResolution resolution = new ScaledResolution(mc);
			float w = resolution.getScaledWidth();
			float h = resolution.getScaledHeight();
			float scale = 32F;
			float u = 1F / (scale / w);
			float v = 1F / (scale / h);
			Minecraft.getMinecraft().entityRenderer.setupOverlayRendering();
			//			GlStateManager.disableLighting();
			GlStateManager.enableBlend();
			GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
			GlStateManager.shadeModel(GL11.GL_SMOOTH);
{'fraction_non_alphanumeric': 0.12371351665171267, 'fraction_numerical': 0.013089143400010555, 'mean_word_length': 4.468398268398269, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3103789', 'n_tokens_mistral': 7406, 'n_tokens_neox': 6394, 'n_words': 1177}