package com.zivilon.cinder_loe.mixins;

import com.zivilon.cinder_loe.CinderLoE;
import lotr.common.LOTRMod;
import lotr.common.entity.animal.LOTREntityBear;
import lotr.common.entity.npc.LOTREntityWarg;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;


@Mixin(LOTREntityBear.class)
public abstract class MixinLOTREntityBear extends Entity {

    public MixinLOTREntityBear(World worldIn) {
        super(worldIn);
    }


    @Shadow(remap = false)
    public abstract LOTREntityBear.BearType getBearType();

    /**
     * @author KeyLime17
     * @reason Mevans
     */
    @Overwrite(remap = false)
    protected void func_70628_a(boolean flag, int i) {
        Item furItem = null;
        int furMeta = 0;
        switch(getBearType().bearID) {
            case 0:
                furItem = LOTRMod.fur;
                break;
            case 1:
                furItem = CinderLoE.cinderFurItem;
                furMeta = 5;
                break;
            case 2:
                furItem = CinderLoE.cinderFurItem;
                furMeta = 4;
                break;
        }

        int furs = 1 + this.rand.nextInt(3) + this.rand.nextInt(i + 1);
        for (int l = 0; l < furs; l++)
            entityDropItem(new ItemStack(furItem, 1, furMeta), 0.0F);
        int bones = 2 + this.rand.nextInt(2) + this.rand.nextInt(i + 1);
        for (int j = 0; j < bones; j++)
            dropItem(LOTRMod.wargBone, 1);
        if (flag) {
            int rugChance = 50 - i * 8;
            rugChance = Math.max(rugChance, 1);
            if (this.rand.nextInt(rugChance) == 0)
                entityDropItem(new ItemStack(LOTRMod.wargskinRug, 1, (getBearType()).bearID), 0.0F);
        }
    }

}
