Jump to content

Unbreakable Armor


ezeglace

Recommended Posts

So i have been making armor and one thing i noticed was that when you enter 0 for the durability in the enumarmormaterial, while unbreakable it does not protect you at all.

This is the code that i have written.

public static EnumArmorMaterial armorPure = EnumHelper.addArmorMaterial("Pure", 0, new int[]{10, 16, 14, 10}, 0);

As you can see the durability is set to zero but it does not protect when worn.

is there anyway to have the armor truly unbreakable while protect you as it should?

 

Link to comment
Share on other sites

What happens if you override isDamageable() in your new armor class with something like this?

 

    public boolean isDamageable()    { return false; }

 

I'm guessing that's checked before damage is applied to an item (though I could be way off, I'm still new at this).

 

Nope, that don't work. I'll just go sit quietly now.

Link to comment
Share on other sites

I tried that and unfortunately it does not work

 

I'm poring over the code now (you've piqued my curiosity). The trick is to find out where damage is applied and override that method...  I can say that it doesn't seem to be getDamage, or getItemDamage. Overriding both of those to return 0 doesn't seem to help.

 

Update: It looks like damaging items is handled in the ItemStack class. I was apparently on the right track, but ItemStack.damageItem doesn't pay attention to isDamageable(), just isItemStackDamageable()

 

Maybe an extension from ItemStack overriding isItemStackDamageable or damageItem(), that checks for a flag that your immortal armor has set before applying damage.

Link to comment
Share on other sites

It looks like damaging items is handled in the ItemStack class. I was apparently on the right track, but ItemStack.damageItem doesn't pay attention to isDamageable(), just isItemStackDamageable()

 

Maybe an extension from ItemStack overriding isItemStackDamageable or damageItem(), that checks for a flag that your immortal armor has set before applying damage...

 

Naw, that'll need overrides all the way up to the player to change the armor inventory type...

 

I'm not well-versed in forge events, but I think Mazetar has the right idea. If there's an event you can trap when an item is damaged, you can have it self-heal...

Link to comment
Share on other sites

public ItemArmor(int par1, EnumArmorMaterial par2EnumArmorMaterial, int par3, int par4)

    {

        super(par1);

        this.material = par2EnumArmorMaterial;

        this.armorType = par4;

        this.renderIndex = par3;

        this.damageReduceAmount = par2EnumArmorMaterial.getDamageReductionAmount(par4);

        this.setMaxDamage(par2EnumArmorMaterial.getDurability(par4));

        this.maxStackSize = 1;

        this.setCreativeTab(CreativeTabs.tabCombat);

        BlockDispenser.dispenseBehaviorRegistry.putObject(this, field_96605_cw);

    }

 

 

just saying you could return 0 to that ....

 

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to comment
Share on other sites

        this.damageReduceAmount = par2EnumArmorMaterial.getDamageReductionAmount(par4);

 

just saying you could return 0 to that ....

 

That's the amount of damage the armor takes? I read it as that's the amount of damage it absorbs... damn obfuscation...

Link to comment
Share on other sites

yes, brain not working too well so late

 

but

 

your custom enum armor material should override

 

public int getDurability(int par1)

    {

        return ItemArmor.getMaxDamageArray()[par1] * this.maxDamageFactor;

    }

and that could return Integer.MAX_VALUE

 

the armor wouldnt be unbreakable... but it would sure take a super long time to break

 

other then that i kinda agree with Mazetar, or make a TickHandler that restore this armor type to max durability

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to comment
Share on other sites

Found in Item

 

     /**
     * Called each tick as long the item is on a player inventory. Uses by maps to check if is on a player hand and
     * update it's contents.
     */
    public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) {}

 

Might, perhaps, be overkill...

Link to comment
Share on other sites

Dude int's max value is insanely large, I doubt you can break it at all lols!

 

Edit: re-reading the last posts from you I find it clear that you have all you need to reach A solution to your problem :)

If you guys dont get it.. then well ya.. try harder...

Link to comment
Share on other sites

No idea at the top of my head, but tileEntity of the anvil should reveal this ;)

 

Not true. It is in the EnumToolMaterial xD

 

Which could pose a problem :/

I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Link to comment
Share on other sites

Hehe as I said no idea, but I would assume the anvils inner workings would reveal whatever it was ;)

 

Well that might not be a problem, since you could make your own materials? :)

 

If you guys dont get it.. then well ya.. try harder...

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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