Skip to content

Add Vault Block API#11159

Closed
Boy0000 wants to merge 12 commits into
PaperMC:masterfrom
Boy0000:vault-api
Closed

Add Vault Block API#11159
Boy0000 wants to merge 12 commits into
PaperMC:masterfrom
Boy0000:vault-api

Conversation

@Boy0000
Copy link
Copy Markdown
Contributor

@Boy0000 Boy0000 commented Jul 24, 2024

Adds bunch of basic API to get/set properties of vault blocks

Not finished but opening to get some feedback on structure and whatnot

The API Break with renaming of Vault-api methods get/setTrialSpawnerState -> get/setVaultState needs bytecode modification
If a contributor could sort that before merging this PR

All accessing of VaultServerData is done through TileEntity instead of a snapshot, due to snapshot always having a ServerLevel null
Therefore VaultServerData would always return null
Unsure if its a bug in my implementation or another issue
image

@Boy0000 Boy0000 requested a review from a team as a code owner July 24, 2024 17:08
@Boy0000 Boy0000 marked this pull request as draft July 24, 2024 17:08
@dawon
Copy link
Copy Markdown
Contributor

dawon commented Jul 24, 2024

I would also add methods accepting player UUIDs, so you can manage rewarded players when they are offline/you don't have a Player instance. It is done similarly for example for Wolf owners etc...

Comment thread patches/server/1045-Vault-API.patch Outdated
Comment thread patches/server/1045-Vault-API.patch Outdated
Comment thread patches/api/0483-Vault-API.patch Outdated
* @return the 'vault_state' value
*/
@NotNull
- State getTrialSpawnerState();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might break plugins. Maybe keep those old methods but deprecate them

Copy link
Copy Markdown
Contributor

@notTamion notTamion Jul 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion this is a fine api break, considering this is clearly a wrong name and the methods have not been around for long and since the naming of these methods might cause confusion.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I don't hate the API break here, we cannot break ABI for spigot plugins as those will need to use said methods.
As such, this PR would have to address the conversion in commodore byte code rewriting.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread patches/server/1045-Vault-API.patch Outdated
Comment thread patches/server/1045-Vault-API.patch Outdated
+ return this.rewardedPlayers.contains(uniqueId);
+ }
+
+ public void addToRewardedPlayers(UUID uniqueId) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of AT can be removed if you use your new methods instead and just get the uuid from the player and to reduce the diff a bit you could just change the original method and make a new overload with player, same applies for the api.

Comment thread patches/api/0483-Vault-API.patch Outdated
Comment thread patches/server/1045-Vault-API.patch Outdated
Comment thread patches/server/1045-Vault-API.patch Outdated
+ }
+
+ @Override
+ public void setItemsToEject(final List<ItemStack> itemsToEject) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't check empty item, so i can easily create a corrupted block entity

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty items seems to be checked internally and handled so null and AIR items should work fine ithink
Unless you want me to explicitly mark ItemStack as notnull here
image

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The codec doesn't support those empty item.
For reference here is the stacktrace when you save the world without interacting with the vault (or using the data command): https://pastes.dev/faeBdNZWcj

Comment thread patches/server/1045-Vault-API.patch Outdated
@Boy0000 Boy0000 marked this pull request as ready for review August 3, 2024 13:13
@Lulu13022002
Copy link
Copy Markdown
Contributor

You should also check with requirePlaced/isPlaced to take in account unplaced blockstate for all methods that works on the block entity directly (and require a level to be set) and not the snapshot

@Boy0000 Boy0000 requested a review from Lulu13022002 August 8, 2024 22:46
Comment thread patches/api/0483-Vault-API.patch Outdated
* @return the 'vault_state' value
*/
@NotNull
- State getTrialSpawnerState();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Boy0000
Copy link
Copy Markdown
Contributor Author

Boy0000 commented Dec 8, 2024

merged onto master for 1.21.4 🙏

@Warriorrrr Warriorrrr mentioned this pull request Feb 4, 2025
@Warriorrrr Warriorrrr moved this from Changes required to Waiting For Author in Paper PR Queue Mar 5, 2025
@kennytv kennytv added the pre-softspoon: never rebased Pre-hardfork pull requests that were not re-opened with the new main branch label Mar 23, 2025
@kennytv kennytv deleted the branch PaperMC:master March 23, 2025 19:16
@kennytv kennytv closed this Mar 23, 2025
@Boy0000 Boy0000 deleted the vault-api branch June 5, 2025 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pre-softspoon: never rebased Pre-hardfork pull requests that were not re-opened with the new main branch pre-softspoon

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.