Search in sources :

Example 1 with Artifact

use of ivorius.reccomplex.random.Artifact in project RecurrentComplex by Ivorforce.

the class ArtifactItem method any.

@Nonnull
public static ItemStack any(Random random) {
    Set<ItemStack> stacks = artifacts.keySet();
    ItemStack[] stackArray = stacks.toArray(new ItemStack[stacks.size()]);
    ItemStack origStack = stackArray[random.nextInt(stackArray.length)];
    ItemStack artifactStack = origStack.copy();
    int enchantLevel = random.nextInt(20);
    List enchantments = EnchantmentHelper.buildEnchantmentList(random, artifactStack, enchantLevel, false);
    if (enchantments.isEmpty()) {
        enchantments = EnchantmentHelper.buildEnchantmentList(random, new ItemStack(Items.IRON_AXE), enchantLevel, false);
    }
    if (!enchantments.isEmpty()) {
        for (Object enchantment : enchantments) {
            EnchantmentData enchantmentdata = (EnchantmentData) enchantment;
            artifactStack.addEnchantment(enchantmentdata.enchantment, enchantmentdata.enchantmentLevel);
        }
    }
    List<String> possibleNames = artifacts.get(origStack);
    Artifact artifact = Artifact.randomArtifact(random, possibleNames.get(random.nextInt(possibleNames.size())));
    artifactStack.setStackDisplayName(artifact.getFullName());
    return artifactStack;
}
Also used : ItemStack(net.minecraft.item.ItemStack) EnchantmentData(net.minecraft.enchantment.EnchantmentData) Artifact(ivorius.reccomplex.random.Artifact) Nonnull(javax.annotation.Nonnull)

Aggregations

Artifact (ivorius.reccomplex.random.Artifact)1 Nonnull (javax.annotation.Nonnull)1 EnchantmentData (net.minecraft.enchantment.EnchantmentData)1 ItemStack (net.minecraft.item.ItemStack)1