Skip to content

Instantly share code, notes, and snippets.

@TheXFactor117
Created July 7, 2017 21:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheXFactor117/a1afcf87091e00b66d282917a5df9a6c to your computer and use it in GitHub Desktop.
Save TheXFactor117/a1afcf87091e00b66d282917a5df9a6c to your computer and use it in GitHub Desktop.
/**
* Creates the given item with randomized attributes and such.
* @param stack
* @param player
*/
public static void createWeapon(ItemStack stack, EntityPlayer player)
{
NBTTagCompound nbt = NBTHelper.loadStackNBT(stack);
IPlayerInformation playerInfo = player.getCapability(CapabilityPlayerInformation.PLAYER_INFORMATION, null);
if (playerInfo != null)
{
if (Rarity.getRarity(nbt) == Rarity.DEFAULT)
{
nbt.setInteger("HideFlags", 6); // hides Attribute Modifier and Unbreakable tags
Rarity.setRarity(nbt, Rarity.getRandomRarity(nbt, player.getEntityWorld().rand)); // sets a random rarity
nbt.setInteger("Level", 1); // set level to current player level
setRandomAttributes(stack, nbt, Rarity.getRarity(nbt), player);
setAttributeModifiers(nbt, stack, player);
stack.setStackDisplayName(Rarity.getRarity(nbt).getColor() + stack.getDisplayName());
NBTHelper.saveStackNBT(stack, nbt);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment