package ru.dbotthepony.mc.otm.mixin;

import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.server.packs.resources.ResourceProvider;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import ru.dbotthepony.mc.otm.client.render.GlitchRenderer;
import ru.dbotthepony.mc.otm.client.render.RenderHelperKt;

@Mixin(GameRenderer.class)
public class MixinGameRenderer {
	@Inject(
		method = "render(FJZ)V",
		at = @At(
			value = "INVOKE",
			target = "Lcom/mojang/blaze3d/pipeline/RenderTarget;bindWrite(Z)V"
		)
	)
	private void render(float p_109094_, long p_109095_, boolean p_109096_, CallbackInfo ci) {
		GlitchRenderer.render();
	}

	@Inject(
		method = "reloadShaders(Lnet/minecraft/server/packs/resources/ResourceProvider;)V",
		at = @At("HEAD")
	)
	private void reloadShaders(ResourceProvider p_250719_, CallbackInfo ci) {
		RenderHelperKt.reloadShaders(p_250719_);
	}
}
