Skip to content

Instantly share code, notes, and snippets.

@TheXFactor117
Created September 17, 2015 00:53
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/9a52c8a49cbe71463123 to your computer and use it in GitHub Desktop.
Save TheXFactor117/9a52c8a49cbe71463123 to your computer and use it in GitHub Desktop.
public class EventItemCrafted
{
@SubscribeEvent
public void onItemCrafted(ItemCraftedEvent event)
{
ItemStack stack = event.crafting;
NBTTagCompound nbt = stack.getTagCompound();
if (stack.getItem() instanceof ItemSword)
{
if (nbt == null)
{
nbt = new NBTTagCompound();
stack.setTagCompound(nbt);
boolean developmentEnvironment = (Boolean)Launch.blackboard.get("fml.deobfuscatedEnvironment");
if (developmentEnvironment || ConfigHandler.enableDevFeatures)
{
RandomCollection<String> rarities = new RandomCollection<String>();
rarities.add(0.65D, "basic");
rarities.add(0.17D, "uncommon");
rarities.add(0.11D, "rare");
rarities.add(0.05D, "legendary");
rarities.add(0.02D, "ancient");
String rarity = rarities.next();
LogHelper.info(rarity);
if (rarity == "basic") nbt.setInteger("RARITY", 1);
if (rarity == "uncommon") nbt.setInteger("RARITY", 2);
if (rarity == "rare") nbt.setInteger("RARITY", 3);
if (rarity == "legendary") nbt.setInteger("RARITY", 4);
if (rarity == "ancient") nbt.setInteger("RARITY", 5);
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment