Created
July 7, 2017 21:24
-
-
Save TheXFactor117/a1afcf87091e00b66d282917a5df9a6c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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