Jump to content

Item Damage


himan54

Recommended Posts

Hello all!

I started working on my mod again, and whilst doing that I decided Id make a hammer (Note: I called it disassembler because at the time I thought it'd be less like a hammer. I was wrong so I will be changing that regardless). I've got it working mostly they way I like it except for these two problems:

1. Once the tool is used it takes 27 damage (Because it can break that many blocks at a time) and as far as I know , it does that, but it causes the durability bar to go crazy. After a couple uses the bar goes past the point where a normal tool would've broken, then goes bright red, then resets. (I can get screenshots if they are necessary)

2. I recently noticed that it is capable of breaking bedrock and other blocks that should be unbreakable so long as the block you originally struck was one of the blocks it is allowed to break. I'm really not sure why.

 

Here is my github repo(https://github.com/rbuxton1/ryansmod), the class in question is under ryansmod/common/tool/DiamondDisassembler. Thanks!

 

(Note: I really cant get

Link to comment
Share on other sites

 for (int ix = -1; ix < 2; ix++)
    		 {
    			 for (int iy = -1; iy < 2; iy++) 
    			 {
    				 for (int iz = -1; iz < 2; iz++)
    				 {
    					 Block canIBreak = world.getBlock(ix, iy, iz);
                                                 if (canIBreak.equals(Blocks.cobblestone) || canIBreak.equals(Blocks.stone) || canIBreak.equals(Blocks.stonebrick) || canIBreak.equals(Blocks.sandstone))
                                                 {
                                                      world.func_147480_a(x+ix, y+iy, z+iz, true);
                                                      item.damageItem(1,player);
    					 }
    				 }
    			 }
    		 }

 

inside you have your item.setItemDamage(item.getItemDamage() + 27); in the triple forloop just make it add 1 not 27. that way it only procs when it works, might want to move it into the if statement too (if breaks something, damage myself, if not move on)

 

and the reason why it can break the unbreakable or untargeted is because you get your boolean then you just go to town with that. just as long as you broke one of the target blocks everything else is fair game. use your check right in the for loop nest

 

 

 

the item = null part may crash minecraft so hopefully you don't need it, but the idea is there

 

Link to comment
Share on other sites

ah I see this is your error:

item.damageItem(item.getItemDamage() + 1, entity);

just use

item.damageItem(1, entity);

 

why is that killing it so fast well

 

break something once

0 + 0 + 1

break another

1 + 1 + 1

3 + 3 + 1

7 + 7 +1

15 + 15 + 1

so on and so forth the first number is the damage of the item already, the second is you grabbing the damage, then adding 1. It basically breaks faster the more you use it.

 

so just need

item.damageItem(1, entity);

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



×
×
  • Create New...

Important Information

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