I use this to give a sword Fire Aspect when crafted.
ItemStack blazefireEnchanted= new ItemStack(Main.blazefireSaber); blazefireEnchanted.addEnchantment(Enchantment.fireAspect, 2); GameRegistry.addShapedRecipe(blazefireEnchanted, new Object[] { " A ", " A ", " B ", 'A', Items.blaze_rod, 'B', Items.blaze_powder });
I'm not sure how you would get it in creative tabs, though.
I can't figure out where in all of the base code enchantments are actually given uses, otherwise I'd be of more help.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
getSubItems is called by creative tabs to add variations of each item to the tab (if the item belongs in that tab). If you override it and add an ItemStack of your item with the appropriate enchantment to the List parameter, that enchanted item should appear in the creative tab.
You can call itemStack.addEnchantment(Enchantment.fireAspect, 1) to add Fire Aspect I to an ItemStack.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
I was wondering if there was a way to make a sword with a default enchantment?
Like when you craft it, give it, or in creative tabs... There would already be the enchantment...
Here are my codes:
//Material
public static final ToolMaterial Random = EnumHelper.addToolMaterial("Random", 3, 1561, 8.0F, 3.0F, 10);
//Tools
public static Item lootingSword = new lootingSword(Random);
public class lootingSword extends ItemSword
{
public lootingSword(ToolMaterial material)
{
super(material);
this.setUnlocalizedName("lootingSword");
this.setTextureName(References.MODID + ":" + "lootingSword");
this.setCreativeTab(Randomod.tabRandoMod);
}
}
EDIT: Actually it doesn't have to be enchanted, I just want my sword to have a really powerful looting boost, like better than with an enchant...
Thank you!
I am most likely inactive on this account! If you want to contact me, here's my Twitter @PandawanMT.
Check out my website!
So close to releasing my new map! Gonna beta test it next week... Probably coming out in two weeks! Follow My Twitter for more info!
ItemStack blazefireEnchanted= new ItemStack(Main.blazefireSaber);
blazefireEnchanted.addEnchantment(Enchantment.fireAspect, 2);
GameRegistry.addShapedRecipe(blazefireEnchanted, new Object[]
{
" A ", " A ", " B ", 'A', Items.blaze_rod, 'B', Items.blaze_powder
});
I'm not sure how you would get it in creative tabs, though.
I can't figure out where in all of the base code enchantments are actually given uses, otherwise I'd be of more help.
public void onCreated(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
par1ItemStack.addEnchantment(Enchantment.looting, 20);
}
But it only works when crafting it... While if I give it/ creative mode... Doesn't work
I am most likely inactive on this account! If you want to contact me, here's my Twitter @PandawanMT.
Check out my website!
So close to releasing my new map! Gonna beta test it next week... Probably coming out in two weeks! Follow My Twitter for more info!
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
I am most likely inactive on this account! If you want to contact me, here's my Twitter @PandawanMT.
Check out my website!
So close to releasing my new map! Gonna beta test it next week... Probably coming out in two weeks! Follow My Twitter for more info!
getSubItems is called by creative tabs to add variations of each item to the tab (if the item belongs in that tab). If you override it and add an ItemStack of your item with the appropriate enchantment to the List parameter, that enchanted item should appear in the creative tab.
You can call itemStack.addEnchantment(Enchantment.fireAspect, 1) to add Fire Aspect I to an ItemStack.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Put this in your sword class:
public boolean hitEntity(ItemStack stack, EntityLivingBase living, EntityLivingBase living2)
{
stack.damageItem(1, living2);
living.setFire(10);
return true;
}
Just change the setFire time to whatever you want.