com.magistuarmory.util.MobEquipmentHelper Maven / Gradle / Ivy
package com.magistuarmory.util;
import com.magistuarmory.EpicKnights;
import net.minecraft.util.RandomSource;
import net.minecraft.world.Difficulty;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.item.*;
import java.util.List;
public class MobEquipmentHelper
{
public static void equip(LivingEntity entity)
{
if (!entity.f_19853_.m_5776_() && EpicKnights.GENERAL_CONFIG.equipMonsters && (!EpicKnights.GENERAL_CONFIG.equipMonstersOnlyIfHard || entity.f_19853_.m_46791_().equals(Difficulty.HARD)))
{
RandomSource rand = entity.f_19853_.m_213780_();
List equipments = MobEquipment.get(entity);
if (equipments.size() > 0)
equipments.get(rand.m_188503_(equipments.size())).equip(entity, rand);
}
}
static void setRandomItemSlot(LivingEntity entity, EquipmentSlot slot, List extends Item> items, double chance, RandomSource rand)
{
if (items.size() == 0)
{
if (EpicKnights.GENERAL_CONFIG.overrideEquipment)
entity.m_8061_(slot, new ItemStack(Items.f_41852_));
return;
}
int id = rand.m_188503_((int) (items.size() / chance));
if (id < items.size())
entity.m_8061_(slot, new ItemStack(items.get(id)));
else if (EpicKnights.GENERAL_CONFIG.overrideEquipment)
entity.m_8061_(slot, new ItemStack(Items.f_41852_));
}
}