if you take the pumpkin off the item bar will stop decreasing... when you put the camera on agen you the effect timer will be the same as when you left it(I guess that I will have to detect the itembar?).
Decreasing the uses left of an item in your inventory is really difficult.
I thought about a different design, tell me if you like it.
Every time you shoot a bow the player gets a score of, for example, 100.
Each second the score decreases of 1 point.
Only the players with a minimum score of 1 will get the night vision effect while using the pumpkin.
I know that it doesn't use the item bar, but unless there a system that I've never heard of (don't think there is) you'd need to use an awful amount of command blocks and the system wouldn't work nicely at all.
I wil make it so identical to the Game OUTLAST as possible.
I've never played outlast, so I don't know its mechanics.
The only thing that is different in my design is that the time left is shown in the scoreboard and not in the item bar. If you want to use the item bar, you need one command block for each possible damage value, which means 384 command blocks just to give the new item to make it look like it's being used. Another 384 if you want to detect the uses left.
the bar will just show the lifetime so I will only need 14 commandblocks to make the item life bar work... the harder thing is to make it remember how long there is left on the night-vision...
As I said, use a scoreboard objective as the timer itself, so you can give to the player a score equals to the time left. Then you can use the bow to restart the time (=reload) and for displaying the time left.
When the player is using the night vision, his score decreases and when it reaches specific values the bow he has will be replaced with a bow with less uses left.
And I've written four sentences that end with the word left.
sure sounds great with a scorebord timer! what commands then?
If you're constantly giving the player 11 seconds of night vision (which you are if you use MegaDerf's method) then you are much better off using a clock that runs at least 1 time per second, and giving the player only 1 second of night vision when they meet the requirements. Now you no longer have to remove the effect when they don't match, and they will never lose the night vision if they are supposed to have it.
I think the flashing when the effect runs out is something I want to have left (it is something like that in the game too). in the game a battery is 150 sec. I think that just set the effect in 150 sec would work. the problem is more to make the effect start with the same time left ass when you took your pumpkin off.
/scoreboard player set @a[score_BatteryTimer=499,score_BatteryTimer_min=499] ChangeBow3 0 [No output]
This is just an example, and you should test it because I'm not 100% sure about it. You need a system like this for each time you want to change the bow. If the player has more than one bow (but no stacked in the same item slot) you need to run this command instead of the second one:
/clear @a[score_BatteryTimer_min=1] minecraft:bow X 1
Then take out one point from the players that have a score that will give a new bow. For example, if you give a bow with half durability to the player with 200 points (that's a random number, is just an example) you remove a point to all the player that have exactly 200 points. That way the new bows will be given only once. To avoid the durability of the batteries being changed, increase the maximum score of as many points as the number of different stages of bows. For example, if the maximum score was 100 and you have 13 different bow stages, increase the maximum score to 113 and change the number of points at which the new bow is given so it will still be proportional.