Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[RESOLVED][1.7.10] How can I make a Battery Item Based In Durability?


Alanzote
 Share

Recommended Posts

Hello! I am making a technical mod, I know a lot in GUI, Models, Blocks, but I know a little bit in Items... =(

And I want to make a Battery that shows a Durability Bar and this bar represents it's energy like this photo:

width=231 height=139http://vignette2.wikia.nocookie.net/mctechnicpack/images/6/6f/Powering_a_machine.png/revision/latest?cb=20120311220125[/img]

and when I add the item to the GUI(Allready made) you see the bar depleting just like some technical mods.(Like it is damaging the Item)

Thanks!

Link to comment
Share on other sites

You can return whatever value you want for the durability bar. Use the showDurabilityBar and getDurabilityForDisplay methods in your Item for that.

I know about that, I've also created a ToolMaterial, but I can't assign a material to a normal Item that has no "abilities"(Sword, Hoe, Pickaxe...)

So How do I do that?

Link to comment
Share on other sites

This has nothing to do with a tool material or Item damage. In that 2nd method you posted you can return ANY value you want. Be it the actual damage value or some data you get out of the NBT of the ItemStack or even the current room temperature (in lack of a better example).

My idea was using a Material for the Item - MaxDurability as the MaxPower - Durability as CurrentPower - but  the way I found was: create 2 variables: MaxPower and Power both defined, then on getDurabilityBarForDisplay I divide them Power/MaxPower, it gives me what I want, but using another block, how can I change this variables?

Link to comment
Share on other sites

Then if you want to change it, well, just change it.

 

magic.png

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Got It in a Very Very Very Stupid Way! I made the Item as a pickaxe and I used ToolMaterial in it adding Durability as Power, and when you add the Item to the GUI I made, it uses slot[0].setItemDamage(slot[0].getItemDamage() + 10) so it damages the item trought time it is there and add power, when the Item has no Durability it won't add. So, latest problem is: How can I slow down The For?!

 

For Code:
if(ItemStack.areItemStacksEqual(slots[0], new ItemStack(ITEM)))
{
	if(slots[0].getItemDamage() >= slots[0].getMaxDamage())
	{

	}
	else
	{
		for(i=0;i<10000;i++){
			power = power+1;
			slots[0].setItemDamage(slots[0].getItemDamage() + 1);
	}
}

How can I slow this down?

Also, make the ToolMaterial worse than Gold and Wood, it does no damaged to blocks!

Link to comment
Share on other sites

Do not create a new ItemStack in order to compare the itemstack's item.  Use ItemStack.getItem()

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

I just want to slow down the power add, the ToolMaterial works for every block that needs power, but if I use as a normal variable, I can't change it using a TileEntity, that's why a ToolMaterial, also, I don't need to save things into NBTTAG, the game saves auto then.

Link to comment
Share on other sites

You do not need to use ToolMaterial to use ItemDamage. Not sure I get what you said there with NBT.

About slowing it down, just increase/decrease less often (e.g. only every 3rd tick).

Just Inclrease/decreate what?

That's True I don't need to Use ToolMaterial Fort that... Trying with "setMaxDamage"

Link to comment
Share on other sites

RESULT: Without ToolMaterial the game Crashes before Mojang Logo

 

You're probably trying to extend ItemTool, which you do not need to do, in order for items to have durability.  ALL ITEMS have the possibility of having a damage value.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Sorry, it was a Stupid Error! =( I forgot to make if(slots[0] !=null) so then CRASH, but now worked, I used setMaxDamage(int); on the Item and it worked, perfectly! Now just need the "slow down" on the power adding(means that when I add power it will slowly add, not add in one single tick)

Link to comment
Share on other sites

onUpdate {
takeALittlePower();
}

takeALittlePower() {
power += 1;
slot[0].damageItem(1);
}

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

magic.png

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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

 Share



×
×
  • Create New...

Important Information

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