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

    • where opportunities abound and promises of financial prosperity beckon from every corner of the internet, the line between opportunity and deception becomes increasingly blurred. As a 38-year-old single mom, I embarked on a journey into the world of cryptocurrency investing, hoping to secure a brighter future for myself and my family. Little did I know, this journey would lead me down a treacherous path fraught with deception and heartbreak. My foray into cryptocurrency investing began with the promise of lucrative returns from a platform claiming to operate within Europe and South Asia. Blinded by optimism and the allure of financial gain, I entrusted my hard-earned savings to this fraudulent company, believing wholeheartedly in its legitimacy. However, my hopes were dashed when I began encountering difficulties with withdrawals and found myself entangled in a web of exorbitant fees and dubious practices. In a desperate bid to salvage what remained of my investment, I turned to a recovery company recommended to me by the very platform that had deceived me. Yet, even in my darkest hour, the deceit persisted, as I soon discovered that the company tasked with recovering my funds was complicit in the deception. Faced with the crushing realization that I had been betrayed once again, I felt a sense of hopelessness engulf me. It was in this moment of despair that I stumbled upon Lee Ultimate Hacker – a shining beacon of hope amidst the darkness of deception. Through a stroke of luck, I came across a blog post singing the praises of this remarkable team, and I knew I had found my savior. With nothing left to lose and everything to gain, I reached out to them, hoping against hope for a chance at redemption. From the outset, Lee Ultimate Hacker proved to be a guiding light in my journey toward financial recovery. Their professionalism, expertise, and unwavering commitment to client satisfaction set them apart from the myriad of recovery services in the digital sphere. With empathy and understanding, they listened to my story and embarked on a mission to reclaim what was rightfully mine. Through their diligent efforts and meticulous attention to detail, Lee Ultimate Hacker succeeded where others had failed, restoring a sense of hope and security in the wake of betrayal. Their dedication to justice and unwavering determination to deliver results ensured that I emerged from the ordeal stronger and more resilient than ever before. Throughout the recovery process, their team remained accessible, transparent, and supportive, offering guidance and reassurance every step of the way. To anyone grappling with devastating financial fraud, I offer a lifeline of hope – trust in Lee Ultimate Hacker to guide you through the storm with expertise and compassion. In a world rife with deception and uncertainty, they stand as a beacon of reliability and trustworthiness, ready to lead you toward financial restitution and a brighter future. If you find yourself in a similar predicament, do not hesitate to reach out to Lee Ultimate Hacker.AT LEEULTIMATEHACKER@ AOL. COM   Support @ leeultimatehacker . com.  telegram:LEEULTIMATE   wh@tsapp +1  (715) 314  -  9248  https://leeultimatehacker.com
    • Sorry, this is the report https://paste.ee/p/OeDj1
    • Please share a link to your crash report on https://paste.ee, as explained in the FAQ
    • This is the crash report [User dumped their crash report directly in their thread, triggering the anti-spam]  
    • Add the crash-report or latest.log (logs-folder) with sites like https://paste.ee/ and paste the link to it here  
  • Topics

×
×
  • Create New...

Important Information

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