package com.acethewildfire.acesbs.mixin;

import com.acethewildfire.acesbs.AcesBS;
import com.acethewildfire.acesbs.villager.ModVillagers;
import net.minecraft.entity.passive.VillagerEntity;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.village.VillagerData;
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(VillagerEntity.class)
public abstract class VillagerFireMixin {

    @Inject(method = "setVillagerData", at = @At("TAIL"))
    private void applyBurningWizardFire(VillagerData villagerData, CallbackInfo ci) {

        VillagerEntity villager = (VillagerEntity)(Object)this;

        if (villagerData.getProfession() == ModVillagers.BURNING_WIZARD) {
            NbtCompound nbt = new NbtCompound();
            villager.writeNbt(nbt);
            nbt.putBoolean("HasVisualFire", true);
            villager.readNbt(nbt);
        } else {
            NbtCompound nbt = new NbtCompound();
            villager.writeNbt(nbt);
            nbt.putBoolean("HasVisualFire", false);
            villager.readNbt(nbt);
        }

    }

}
