package me.deftware.mixin.mixins;

import me.deftware.client.framework.event.events.EventWeather;
import me.deftware.client.framework.maps.SettingsMap;
import net.minecraft.block.BlockState;
import net.minecraft.client.render.Camera;
import net.minecraft.client.render.LightmapTextureManager;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.WorldRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.Registry;
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;

@Mixin(WorldRenderer.class)
public class MixinWorldRenderer {

    @Inject(method = "method_22713", at = @At("HEAD"), cancellable = true)
    private void renderRain(Camera camera, CallbackInfo ci) {
        EventWeather event = new EventWeather(EventWeather.WeatherType.Rain);
        event.broadcast();
        if (event.isCanceled()) {
            ci.cancel();
        }
    }

    @Inject(method = "drawBlockOutline", at = @At("HEAD"), cancellable = true)
    private void drawBlockOutline(MatrixStack matrixStack, VertexConsumer vertexConsumer, Entity entity, double d, double e, double f, BlockPos blockPos, BlockState blockState, CallbackInfo ci) {
        if (SettingsMap.isOverrideMode() || (SettingsMap.isOverwriteMode() && SettingsMap.hasValue(Registry.BLOCK.getRawId(blockState.getBlock()), "outline"))) {
            boolean doRender = (boolean) SettingsMap.getValue(Registry.BLOCK.getRawId(blockState.getBlock()), "outline", true);
            if (!doRender) {
                ci.cancel();
            }
        }
    }

    @Inject(method = "renderWeather", at = @At("HEAD"), cancellable = true)
    private void renderWeather(LightmapTextureManager manager, float f, double d, double e, double g, CallbackInfo ci) {
        EventWeather event = new EventWeather(EventWeather.WeatherType.Rain);
        event.broadcast();
        if (event.isCanceled()) {
            ci.cancel();
        }
    }

}

@@ -95,101 +95,8 @@
 er;%0A
-import me.deftware.client.framework.maps.SettingsMap;%0Aimport net.minecraft.block.BlockState;%0A
 impo
@@ -232,245 +232,21 @@
 der.
-VertexConsumer;%0Aimport net.minecraft.client.render.WorldRenderer;%0Aimport net.minecraft.client.util.math.MatrixStack;%0Aimport net.minecraft.entity.Entity;%0Aimport net.minecraft.util.math.BlockPos;%0Aimport net.minecraft.util.registry.Registry
+WorldRenderer
 ;%0Aim
@@ -841,662 +841,8 @@
  %7D%0A%0A
-    @Inject(method = %22drawBlockOutline%22, at = @At(%22HEAD%22), cancellable = true)%0A    private void drawBlockOutline(MatrixStack matrixStack, VertexConsumer vertexConsumer, Entity entity, double d, double e, double f, BlockPos blockPos, BlockState blockState, CallbackInfo ci) %7B%0A        if (SettingsMap.isOverrideMode() %7C%7C (SettingsMap.isOverwriteMode() && SettingsMap.hasValue(Registry.BLOCK.getRawId(blockState.getBlock()), %22outline%22))) %7B%0A            boolean doRender = (boolean) SettingsMap.getValue(Registry.BLOCK.getRawId(blockState.getBlock()), %22outline%22, true);%0A            if (!doRender) %7B%0A                ci.cancel();%0A            %7D%0A        %7D%0A    %7D%0A%0A
     

Remove unused Mixin