Conversation
This listener can be used by calling Builder#onPrepare. It will be triggered whenever a change to the item name has been made (WesJD#231).
|
I really appreciate this PR. Sorry I haven't gotten a chance to look at it yet. Looking at the original issue, the person mentions being able to modify the title or another element of the anvil in onPrepare. How do you think we should handle that? |
|
there is a generic title updater for all containers. if you want you can implement. it uses reflections but you can make it in nms modules too. |
I think we could use a The window title can be changed by re-sending the window open packet, the method is already there in the wrapper. However, when you update the left input item's display name before sending the window open packet, it will also update the input text field to this value, so this could be a way around it. But with this method, the name of the input item and the input field are the same, so there is no output item. So, whenever updating the inventory title, there is no output item, since both strings are the same. My solution is to add an enchanted book to the right slot, which will always force an output item and thus allow title updates: Peek.2022-11-12.21-11.mp4I don't know if there is a better solution for this, I think this is the only way for a smooth experience without clearing/blocking the output slot when updating the window title. |
|
Thanks for the research you did on this. The enchanted book idea is definitely interesting, but I think limits the usability of the library by other developers. Based on your findings, I don't think it is really worth implementing this feature. It looks weird for the user, and it feels like the creator of the issue probably need this on a one-off case for likely just a cool small add on. Feels too limiting to add in. |
see #231.
Tested both on 1.8 and 1.19 with the new
onPreparefunction set, seems to work without causing any errors. I've registered the PrepareAnvilEvent using thePluginManager#registerEventmethod, since it can't be in the same Listener class for mc < 1.9.