Jump to content

Recommended Posts

Posted

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?

 

Posted
:-\ if you put it to 9999999 by the time you die you still have durabilty. And why it wont work is because at 0 its technically broken, minecraft counts it broken, causing 0 protection.

Not new to java >> New to modding.

Posted

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.

Posted

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.

Posted

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...

Posted

I was just thinking that you guys may be overthinking this, stupid simple is usualy better than bulky, confusing, overkill ;)

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

Posted

well if i knew how to do that then problem solved, but it still bugs me that i cant make armor unbreakable and protective. i wonder how ee2 did it with the gem armor

Posted

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-

Posted

        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...

Posted

oh ... well if its the amount it absorbs .. just make it

Integer.MAX_VALUE

wtf am i saying?

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

-hydroflame, author of the forge revolution-

Posted

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-

Posted

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...

Posted

Okay i think i got it i set the durability to Integer.MAX_VALUE and have it auto-heal (or reset health) somehow can anyone help with that?

 

Posted

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...

Posted

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

Posted

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...

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.