-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow For Default Titles in InventoryView Builders #12013
base: main
Are you sure you want to change the base?
Allow For Default Titles in InventoryView Builders #12013
Conversation
...java/org/bukkit/craftbukkit/inventory/view/builder/CraftDoubleChestInventoryViewBuilder.java
Show resolved
Hide resolved
...in/java/org/bukkit/craftbukkit/inventory/view/builder/CraftStandardInventoryViewBuilder.java
Show resolved
Hide resolved
...java/org/bukkit/craftbukkit/inventory/view/builder/CraftBlockEntityInventoryViewBuilder.java
Outdated
Show resolved
Hide resolved
...java/org/bukkit/craftbukkit/inventory/view/builder/CraftBlockEntityInventoryViewBuilder.java
Outdated
Show resolved
Hide resolved
...java/org/bukkit/craftbukkit/inventory/view/builder/CraftBlockEntityInventoryViewBuilder.java
Outdated
Show resolved
Hide resolved
...java/org/bukkit/craftbukkit/inventory/view/builder/CraftBlockEntityInventoryViewBuilder.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe MenuType#create could have a new method without title and a nullable title.
Also i get this error while testing the lectern: https://pastes.dev/KgmpW6mqCE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The loom has the title of the chest set by default.
I also get some other errors while testing
for the enchantment menu: https://pastes.dev/ZgBP7TjW9Y
for the merchant menu: https://pastes.dev/whPBf9wNNc
|
I get another error when i tried to open a merchant menu without villager but with a title set: https://pastes.dev/hLGHRQQSSt And the loom is still disguised as a chest. |
c333083
to
16aba18
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two small comments but otherwise all looks good to me
...java/org/bukkit/craftbukkit/inventory/view/builder/CraftBlockEntityInventoryViewBuilder.java
Outdated
Show resolved
Hide resolved
@@ -140,16 +142,16 @@ public static <V extends InventoryView, B extends InventoryViewBuilder<V>> MenuT | |||
return asType(new MenuTypeData<>(InventoryView.class, () -> new CraftBlockEntityInventoryViewBuilder<>(handle, Blocks.SHULKER_BOX, ShulkerBoxBlockEntity::new))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If opening noises should be prevented (as is done with chest using useFakeBlockEntity), then perhaps that could be done here too with the shulker.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah The whole shulker thing is a bit more nuanced due to the need for it to be distinctly different than a chest with GENERIC_9x3. In the interest of trying to keep this PR focused on adding default titles, this will need to be addressed in a PR where I rewrite the opening logic that Bukkit does. Long story short getNotchInventoryType isn't actually smart enough to identify the difference between a shulker box and GENERIC_9x3 as they'd be created with this API. The way around this is to define and force the use of the BlockEntity for now* The chest is okay to avoid this because it is a GENERIC_9x3.
This PR addresses a previous critique of no default titles for the InventoryView builders PR. The goal of this PR is to integrate default titles and minimize the explicit declaration of translatable keys to ease on maintenance burden of this API.
I have bundled the test plugin I used along with this PR to ease of testing code if needed.
Below examplifies the change from an API perspective
Within this PR I took a few different approaches to accessing titles. The first two of, which are off of the BlockEntity and Block menu provider respectively. However, there are two cases where I directly declare a Translatable component within this API, once in CraftStandardInventoryViewBuilder and once in CraftDoubleChestInventoryViewBuilder.