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;
}
Aggregations