Started by
Dilly
on
Topic category: Help with Minecraft modding (Java Edition)
I have a question about how to add a progress bar to the GUI of a custom furnace. The furnace system itself works fine, but I can't figure out how to change the sprite for my progress bar.
Also, does this have to be done through procedures?
Yes, it does have to be done through procedures. I've done something similar before, and the best solution I came up with was creating a separate sprite for each progress value, setting each sprite's display condition to a procedure that checks if whatever value (global variable, block NBT value, etc.) is equal to the value you want that progress sprite to be shown at, then layering all the sprites on top of each other.
It's a very convoluted process that takes a lot of repetition, but I've made some working progress bars with it.
Hope this helps :)
Which module is responsible for changing the sprite in the GUI?
If I'm understanding you correctly, I think there should be a "Display Condition" or "Sprite Display Condition" procedure slot in the sprite creation/edit menu.
And I'm assuming you already have a value in the block for furnace progress?
Yes, I have a variable for crafting. But I can't add a procedure to Display Condition
I'm getting an error: Procedure that uses return value must always end with a valid return block
You have to make sure that it always returns a value, including in an IF statement.
For example, if you have:
if progress = 1 {
return true
}
That wouldn't work. You would have to put:
if progress = 1 {
return true
} else {
return false
}
That's basically what that error is saying.
Hope this helps! :)
Actually, slight correction, to the best of my knowledge, I think that you would actually need:
if progress = 1 {
return true
}
return false
I could be mistaken about this, but I'm pretty sure that you need to have one return block at the end of the procedure outside of an if/else statement. (also, my suggestion basically works the same as LordZintick's second suggestion, because the return block will basically exit out of the procedure, so if it is in an if statement, anything past it will only run if the if statement isn't met.)
Other than that, LordZintick's explanation of the error is accurate.
Sorry, my bad. I forgot that MCreator doesn't count the return statement in the else block towards the "Procedure that uses return value must always end with a valid return block" thing.
Oh, I see. I was trying to add a `return` statement in the `else` block. I didn't know that MCreator works that way.
Yeah, it's weird like that.
Did you get the progress bar working?
Yes. Thank you all.
You're very welcome!