Jump to content

[SOLVED(sort of)] Enchantments not appearing for custom weapons


hotrods20

Recommended Posts

I am currently developing a mod that adds some custom weapons.  I am not entirely sure on what is wrong so I'll post code.

 

public static EnumToolMaterial obsidian = EnumHelper.addToolMaterial("OBSIDIAN", 3, -1, 6.0F, 2, 14);
public static Item oSword = new ItemSword(3500, OTMain.obsidian).setCreativeTab(tabObsidianTools).setUnlocalizedName("oSword");
public static Item oAxe = new ItemAxe(3501, OTMain.obsidian).setCreativeTab(tabObsidianTools).setUnlocalizedName("oAxe");
public static Item oHoe = new ItemHoe(3502, OTMain.obsidian).setCreativeTab(tabObsidianTools).setUnlocalizedName("oHoe");
public static Item oPickaxe = new ItemPickaxe(3503, OTMain.obsidian).setCreativeTab(tabObsidianTools).setUnlocalizedName("oPickaxe");
public static Item oSpade = new ItemSpade(3504, OTMain.obsidian).setCreativeTab(tabObsidianTools).setUnlocalizedName("oSpade");

 

The problem I am having is when I place the items in the enchantment table, no enchantments show up.  I can do /enchant and I can place them in Anvils and enchant them.  Any suggestions or anyone know how to get enchantments to appear for these items?

 

Solution:

So, if a tool material has 0 or lower amount of uses, then it won't be able to be enchanted in a enchantment table.  Solution is to modify the tool in its own class to not take any damage from anything.

 

That means if you want to have items that don't suffer from durability loss, you need to have:

@Override
public boolean hitEntity(ItemStack par1ItemStack, EntityLiving par2EntityLiving, EntityLiving par3EntityLiving)
{
	par1ItemStack.damageItem(0, par3EntityLiving);
	return true;
}

@Override
public boolean onBlockDestroyed(ItemStack par1ItemStack, World par2World, int par3, int par4, int par5, int par6, EntityLiving par7EntityLiving)
    {
	par1ItemStack.damageItem(0, par7EntityLiving);
	return true;
    }

 

In each items class file or in a main tools file they all read file.

width=320 height=64http://www.slothygaming.com/img/ota.png[/img]

If your grammar is shit and you blatantly don't know what you're doing, I will not help you.

Link to comment
Share on other sites

I just use the ItemSword.java which is a vanilla class.  By using that and using my custom tool material, it should work.

 

The code from ItemSword.java:

public int getItemEnchantability()
    {
        return this.toolMaterial.getEnchantability();
    }[/Code]

This should work because it gets the ability to be enchanted from the material.

 

My material:

[Code]public static EnumToolMaterial obsidian = EnumHelper.addToolMaterial("OBSIDIAN", 3, -1, 6.0F, 2, 14);[/Code]

The last number in my code is the ability for the item to be enchanted's factor.  That one is equal to iron.  Gold having the highest of course.

width=320 height=64http://www.slothygaming.com/img/ota.png[/img]

If your grammar is shit and you blatantly don't know what you're doing, I will not help you.

Link to comment
Share on other sites

^works too, but it's easier with the code i supplied. Basically, yes this can be enchanted. what can be enchanted onto it is already determined by the item type. either weapon or tool etc. Your doing work minecraft already does. (code supplied is tested)

 

public int getItemEnchantability()

    {

        return 1;

    }

 

in case you missed it from my spam

Never understood why textures were so complicated.

Link to comment
Share on other sites

i'd recommend not using a custom item material for now, and let it be treated as gold iron diamond etc. I honestly don't know how to add enchanting compatibility to custom blocks, it's probably something within the material file.

Never understood why textures were so complicated.

Link to comment
Share on other sites

I've come to the conclusion that when the ItemSword class is looking for a material, it will only accept materials that have been declared in EnumToolMaterial because I had my Obsidian material just copy the EnumToolMaterial.IRON and it let my tool be enchanted.  Is it possibly how the material is added to the game?

width=320 height=64http://www.slothygaming.com/img/ota.png[/img]

If your grammar is shit and you blatantly don't know what you're doing, I will not help you.

Link to comment
Share on other sites

	public static EnumToolMaterial obsidian = EnumHelper.addToolMaterial("OBSIDIAN", 3, -1, 6.0F, 2, 12);
public static Item oSword = new ItemSword(3500, obsidian).setCreativeTab(tabObsidianTools).setUnlocalizedName("oSword");
public static Item oAxe = new ItemAxe(3501, obsidian).setCreativeTab(tabObsidianTools).setUnlocalizedName("oAxe");
public static Item oHoe = new ItemHoe(3502, obsidian).setCreativeTab(tabObsidianTools).setUnlocalizedName("oHoe");
public static Item oPickaxe = new ItemPickaxe(3503, obsidian).setCreativeTab(tabObsidianTools).setUnlocalizedName("oPickaxe");
public static Item oSpade = new ItemSpade(3504, obsidian).setCreativeTab(tabObsidianTools).setUnlocalizedName("oSpade");

That is all the code that I have created in the sense of creating the items.  I have already registered the items and all that.  The sword code can be found in ItemSword in net.minecraft.item.

width=320 height=64http://www.slothygaming.com/img/ota.png[/img]

If your grammar is shit and you blatantly don't know what you're doing, I will not help you.

Link to comment
Share on other sites

I did try adding classes for each item I am adding but it still didn't help.  It seems like the enchantment table just doesn't get the value for my item.  Has any mods made items that can be enchanted via enchantment table?

width=320 height=64http://www.slothygaming.com/img/ota.png[/img]

If your grammar is shit and you blatantly don't know what you're doing, I will not help you.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • i notice a change if i add the min and max ram in the line like this for example:    # Xmx and Xms set the maximum and minimum RAM usage, respectively. # They can take any number, followed by an M or a G. # M means Megabyte, G means Gigabyte. # For example, to set the maximum to 3GB: -Xmx3G # To set the minimum to 2.5GB: -Xms2500M # A good default for a modded server is 4GB. # Uncomment the next line to set it. -Xmx10240M -Xms8192M    i need to make more experiments but for now this apparently works.
    • Selamat datang di OLXTOTO, situs slot gacor terpanas yang sedang booming di industri perjudian online. Jika Anda mencari pengalaman bermain yang luar biasa, maka OLXTOTO adalah tempat yang tepat untuk Anda. Dapatkan sensasi tidak biasa dengan variasi slot online terlengkap dan peluang memenangkan jackpot slot maxwin yang sering. Di sini, Anda akan merasakan keseruan yang luar biasa dalam bermain judi slot. DAFTAR OLXTOTO DISINI LOGIN OLXTOTO DISINI AKUN PRO OLXTOTO DISINI   Slot Gacor untuk Sensasi Bermain Maksimal Olahraga cepat dan seru dengan slot gacor di OLXTOTO. Rasakan sensasi bermain maksimal dengan mesin slot yang memberikan kemenangan beruntun. Temukan keberuntungan Anda di antara berbagai pilihan slot gacor yang tersedia dan rasakan kegembiraan bermain judi slot yang tak terlupakan. Situs Slot Terpercaya dengan Pilihan Terlengkap OLXTOTO adalah situs slot terpercaya yang menawarkan pilihan terlengkap dalam perjudian online. Nikmati berbagai genre dan tema slot online yang menarik, dari slot klasik hingga slot video yang inovatif. Dipercaya oleh jutaan pemain, OLXTOTO memberikan pengalaman bermain yang aman dan terjamin.   Jackpot Slot Maxwin Sering Untuk Peluang Besar Di OLXTOTO, kami tidak hanya memberikan hadiah slot biasa, tapi juga memberikan kesempatan kepada pemain untuk memenangkan jackpot slot maxwin yang sering. Dengan demikian, Anda dapat meraih keberuntungan besar dan memenangkan ribuan rupiah sebagai hadiah jackpot slot maxwin kami. Jackpot slot maxwin merupakan peluang besar bagi para pemain judi slot untuk meraih keuntungan yang lebih besar. Dalam permainan kami, Anda tidak harus terpaku pada kemenangan biasa saja. Kami hadir dengan jackpot slot maxwin yang sering, sehingga Anda memiliki peluang yang lebih besar untuk meraih kemenangan besar dengan hadiah yang menggiurkan. Dalam permainan judi slot, pengalaman bermain bukan hanya tentang keseruan dan hiburan semata. Kami memahami bahwa para pemain juga menginginkan kesempatan untuk meraih keberuntungan besar. Oleh karena itu, OLXTOTO hadir dengan jackpot slot maxwin yang sering untuk memberikan peluang besar kepada para pemain kami. Peluang Besar Menang Jackpot Slot Maxwin Peluang menang jackpot slot maxwin di OLXTOTO sangatlah besar. Anda tidak perlu khawatir tentang batasan atau pembatasan dalam meraih jackpot tersebut. Kami ingin memberikan kesempatan kepada semua pemain kami untuk merasakan sensasi menang dalam jumlah yang luar biasa. Jackpot slot maxwin kami dibuka untuk semua pemain judi slot di OLXTOTO. Anda memiliki peluang yang sama dengan pemain lainnya untuk memenangkan hadiah jackpot yang besar. Kami percaya bahwa semua orang memiliki kesempatan untuk meraih keberuntungan besar, dan itulah mengapa kami menyediakan jackpot slot maxwin yang sering untuk memenuhi harapan dan keinginan Anda.  
    • LOGIN DAN DAFTAR DISINI SEKARANG !!!! Blacktogel adalah situs judi slot online yang menjadi pilihan banyak penggemar judi slot gacor di Indonesia. Dengan platform yang sangat user-friendly dan berbagai macam permainan slot yang tersedia, Blacktogel menjadi tempat yang tepat untuk penggemar judi slot online. Dalam artikel ini, kami akan membahas tentang Blacktogel dan keunggulan situs slot gacor online yang disediakan.  
    • Situs bandar slot online Gacor dengan bonus terbesar saat ini sedang menjadi sorotan para pemain judi online. Dengan persaingan yang semakin ketat dalam industri perjudian online, pemain mencari situs yang tidak hanya menawarkan permainan slot yang gacor (sering memberikan kemenangan), tetapi juga bonus terbesar yang bisa meningkatkan peluang menang. Daftar disini : https://gesit.io/googlegopek
    • Situs bandar slot online Gacor dengan bonus terbesar saat ini sedang menjadi sorotan para pemain judi online. Dengan persaingan yang semakin ketat dalam industri perjudian online, pemain mencari situs yang tidak hanya menawarkan permainan slot yang gacor (sering memberikan kemenangan), tetapi juga bonus terbesar yang bisa meningkatkan peluang menang. Daftar disini : https://gesit.io/googlegopek
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.