package com.zivilon.cinder_loe.mixins;

import com.zivilon.cinder_loe.util.IEntityLivingBase;

import lotr.common.entity.npc.LOTREntityOrc;
import lotr.common.entity.ai.LOTREntityAIOrcSkirmish;

import net.minecraft.entity.EntityLivingBase;

import org.spongepowered.asm.mixin.*;
import org.spongepowered.asm.mixin.injection.*;
import org.spongepowered.asm.mixin.injection.callback.*;

@Mixin(LOTREntityAIOrcSkirmish.class)
public class MixinLOTREntityAIOrcSkirmish {

    /**
     * @author Shinare
     * @reason Disabled skirmishing for warbands
     */
    @Overwrite(remap = false)
    private boolean canOrcSkirmish(EntityLivingBase entity) {
        if (entity instanceof LOTREntityOrc) {
            LOTREntityOrc orc = (LOTREntityOrc)entity;
            if (((IEntityLivingBase)orc).get_warband_uuid() != null) return false;
            return (!orc.isTrader() && !orc.hiredNPCInfo.isActive && orc.ridingEntity == null && orc.canOrcSkirmish());
        }
        return false;
    }
}
