Skip to content
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

Add Vault Block API #11159

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Add Vault Block API #11159

wants to merge 11 commits into from

Conversation

Boy0000
Copy link
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
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...

patches/server/1045-Vault-API.patch Outdated Show resolved Hide resolved
* @return the 'vault_state' value
*/
@NotNull
- State getTrialSpawnerState();
Copy link
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
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
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.

patches/server/1045-Vault-API.patch Outdated Show resolved Hide resolved
patches/server/1045-Vault-API.patch Outdated Show resolved Hide resolved
+ return this.rewardedPlayers.contains(uniqueId);
+ }
+
+ public void addToRewardedPlayers(UUID uniqueId) {
Copy link
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.

patches/api/0483-Vault-API.patch Outdated Show resolved Hide resolved
patches/server/1045-Vault-API.patch Outdated Show resolved Hide resolved
+ }
+
+ @Override
+ public void setItemsToEject(final List<ItemStack> itemsToEject) {
Copy link
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
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
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

patches/server/1045-Vault-API.patch Outdated Show resolved Hide resolved
@Boy0000 Boy0000 marked this pull request as ready for review August 3, 2024 13:13
@Lulu13022002
Copy link
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Changes required
Development

Successfully merging this pull request may close these issues.

7 participants