package ru.dbotthepony.mc.otm.mixin;

import net.minecraft.client.DeltaTracker;
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(Lnet/minecraft/client/DeltaTracker;Z)V",
		remap = false,
		at = @At(
			value = "INVOKE",
			remap = false,
			target = "Lcom/mojang/blaze3d/pipeline/RenderTarget;bindWrite(Z)V"
		)
	)
	private void render(DeltaTracker p_348648_, boolean p_109096_, CallbackInfo ci) {
		GlitchRenderer.render();
	}

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