package greymerk.roguelike.treasure.loot;
import java.util.Random;
import greymerk.roguelike.treasure.loot.provider.ItemArmour;
import greymerk.roguelike.treasure.loot.provider.ItemWeapon;
import greymerk.roguelike.util.TextFormat;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
public enum Loot {
WEAPON, ARMOUR, BLOCK, JUNK, ORE, TOOL, POTION, FOOD, ENCHANTBOOK,
ENCHANTBONUS, SUPPLY, MUSIC, SMITHY, SPECIAL, REWARD, STARTER;
public static ILoot getLoot(){
LootProvider loot = new LootProvider();
for(int i = 0; i < 5; ++i){
loot.put(i, new LootSettings(i));
}
return loot;
}
public static ItemStack getEquipmentBySlot(Random rand, EntityEquipmentSlot slot, int level, boolean enchant){
if(slot == EntityEquipmentSlot.MAINHAND){
return ItemWeapon.getRandom(rand, level, enchant);
}
return ItemArmour.getRandom(rand, level, Slot.getSlot(slot), enchant);
}
public static ItemStack getEquipmentBySlot(Random rand, Slot slot, int level, boolean enchant){
if(slot == Slot.WEAPON){
return ItemWeapon.getRandom(rand, level, enchant);
}
return ItemArmour.getRandom(rand, level, slot, enchant);
}
public static void setItemLore(ItemStack item, String loreText){
NBTTagCompound tag = item.getTagCompound();
if (tag == null){
tag = new NBTTagCompound();
item.setTagCompound(tag);
}
if (!tag.hasKey("display")){
tag.setTag("display", new NBTTagCompound());
}
NBTTagCompound display = tag.getCompoundTag("display");
if (!(display.hasKey("Lore")))
{
display.setTag("Lore", new NBTTagList());
}
NBTTagList lore = display.getTagList("Lore", 0);
NBTTagString toAdd = new NBTTagString(loreText);
lore.appendTag(toAdd);
display.setTag("Lore", lore);
}
public static void setItemLore(ItemStack item, String loreText, TextFormat option){
setItemLore(item, TextFormat.apply(loreText, option));
}
public static void setItemName(ItemStack item, String name, TextFormat option){
if(option == null){
item.setStackDisplayName(name);
return;
}
item.setStackDisplayName(TextFormat.apply(name, option));
}
public static void setItemName(ItemStack item, String name){
setItemName(item, name, null);
}
}