package com.thebrokenrail.herobrine.mixin;

import com.thebrokenrail.herobrine.data.HerobrineData;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.world.World;
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 java.util.function.BooleanSupplier;

@Mixin(ServerWorld.class)
public class MixinServerWorld {
    @Inject(at = @At("HEAD"), method = "tick")
    public void tick(BooleanSupplier shouldKeepTicking, CallbackInfo info) {
        ServerWorld world = ((ServerWorld) (Object) this);
        if (world.getRegistryKey() == World.OVERWORLD) {
            HerobrineData data = HerobrineData.get(world);
            data.tick(world);
        }
    }
}
