Jump to content

[Solved]Sword Confusion?


SureShotM

Recommended Posts

Okay I know I have been posting here a lot recently and I want to make it clear, 1. I am not working on a big huge project that is going to be released I am just trying to relearn some things since the last time I modded was back in 1.4, 2. Eventually with the new Knowledge I gain I do plan on making a mod but not quit sure yet on what I want.

 

Now time for my confusion, so I decided to move to tools and armor cause I've been curious on what I can do with them and so far on my own i was able to make two swords one has a enchant on crafting witch wasn't that hard to do, and the second one has a potion effect when it hits an entity witch again wasn't hard to do I even made a key binding where you can turn off the effect of the second sword. 

 

What led me to the key binding was I wanted the weapon to take different damage based if the effect was on or off, now here is where I'm confused, first I set the max damage to 10(for testing purpose) and then decided to test if that did anything without adding anything to the hit entity function, and nothing happened to the durability at first I decided to look to see if there was any posts on this and I came up with only one post explain he was working with is own material, as for me though I am working with iron as the material.

 

So I did more testing and decided in my hit entity function to set damage to 2 when the effect was off and 5 when it was on(again testing purpose) but every time it would hit any entity instead of subtracting more durability it was only setting the new durability to 8 and 5 now this is were I'm confused why durability will not drop at all.

 

Note: I have took out the set damage part out completely for now in the code but if you would like to see it this is the part class I am working in https://github.com/SureShotM/Moding-For-Fun/blob/master/src/main/java/com/Leo/mff/item/ItemLionsSword.java

~SureShotM/Leo~ gaming coding all around fun!

Link to comment
Share on other sites

I read last two captions (not counting on with link) few times and maybe it's just me (it's late here) but I got totally confused with your damage and durability stuff.

1. Please check your mistakes and/or maybe retype 3rd caption - it's about 100 words in ONE sentence bro.

2. State your question (there is none) - I belive you want explanation?

3. You know if you are using KeyBinding and want server-side to know that your weapon is "active" you have to send packet right?

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

Okay 1. the damage and durability, in forge at least since I last checked the damage(setMaxDamage();) is the durability, when I say durability I'm talking about when I'm in game testing. In other words I'm using two words meaning the same thing.

 

2.  My question would be is,  why is the damage/durability not going down when the sword is being used like a vanilla iron sword?

 

3. Yes I know that, I didn't push my key binding code into my git hub yet, so that would be why its missing.

~SureShotM/Leo~ gaming coding all around fun!

Link to comment
Share on other sites

From  ItemSword.class

    public boolean hitEntity(ItemStack p_77644_1_, EntityLivingBase p_77644_2_, EntityLivingBase p_77644_3_)
    {
        p_77644_1_.damageItem(1, p_77644_3_);
        return true;
    }

 

You sword extended it and you havend added "damageItem(1, p_77644_3_)" at end of your override. The damageItem has to be called by hitEntity (or other if you want, e.g making a wand) to actually damage item. :P

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

Thank you so much you've cleared up my confusion and now understand why I couldn't find the damageItem(), I was trying to run it as hitEntity.damageItem() not stack.damageItem(1, hitEntity). Thank you thank you.

~SureShotM/Leo~ gaming coding all around fun!

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


×
×
  • Create New...

Important Information

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