package top.r3944realms.lib39.mixin.callback.client;

import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.multiplayer.ClientPacketListener;
import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.core.Holder;
import net.minecraft.core.RegistryAccess;
import net.minecraft.resources.ResourceKey;
import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.dimension.DimensionType;
import net.minecraft.world.level.storage.WritableLevelData;
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 top.r3944realms.lib39.api.callback.client.ClientWorldCallback;

import java.util.function.Supplier;

/**
 * The type Mixin client level.
 */
@Mixin(ClientLevel.class)
public abstract class MixinClientLevel extends Level {
    /**
     * Instantiates a new Mixin client level.
     *
     * @param levelData                 the level data
     * @param dimension                 the dimension
     * @param registryAccess            the registry access
     * @param dimensionTypeRegistration the dimension type registration
     * @param profiler                  the profiler
     * @param isClientSide              the is client side
     * @param isDebug                   the is debug
     * @param biomeZoomSeed             the biome zoom seed
     * @param maxChainedNeighborUpdates the max chained neighbor updates
     */
    protected MixinClientLevel(WritableLevelData levelData, ResourceKey<Level> dimension, RegistryAccess registryAccess, Holder<DimensionType> dimensionTypeRegistration, Supplier<ProfilerFiller> profiler, boolean isClientSide, boolean isDebug, long biomeZoomSeed, int maxChainedNeighborUpdates) {
        super(levelData, dimension, registryAccess, dimensionTypeRegistration, profiler, isClientSide, isDebug, biomeZoomSeed, maxChainedNeighborUpdates);
    }
    @Inject(method = "<init>", at = @At("RETURN"))
    private void $init(ClientPacketListener connection, ClientLevel.ClientLevelData clientLevelData, ResourceKey<Level> dimension, Holder<DimensionType> dimensionType, int viewDistance, int serverSimulationDistance, Supplier<ProfilerFiller> profiler, LevelRenderer levelRenderer, boolean isDebug, long biomeZoomSeed, CallbackInfo ci) {
        ClientWorldCallback.LOAD.invoker().onWorldLoad(ClientLevel.class.cast(this));
    }
}
