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

Block data stuff #7071

Open
wants to merge 19 commits into
base: dev/feature
Choose a base branch
from

Conversation

cheeezburga
Copy link
Member

@cheeezburga cheeezburga commented Sep 12, 2024

Description

This PR adds some more basic block data support and block data tags to Skript. It introduces a block -> block data converter, which I'm happy to take feedback on.

Stuff that this PR adds:

  • Getting the block data of a valid item
  • Getting the block data tags of a block data
  • Tests for these

Stuff that will probably also make it into this PR:

  • Getting the value of a tag of a block data
  • Setting the values of tags of block datas

The code in this PR was created without knowledge of SkBee's implementation. At the very end I compared the two, just to see if I had missed anything big, which I (sort of) had. SkBee uses a method, toBlockForm, which converts some itemstacks whose material isn't a valid block to their respective block form (e.g. wheat seeds -> wheat). I couldn't think of any other way to do this, so it was implemented with Shane's permission.


Target Minecraft Versions: 1.13+
Requirements: none
Related Issues: #6087

cheeezburga and others added 12 commits September 9, 2024 15:51
- Allows getting the block data of valid itemtypes
- Adds some methods to get the tags and values of a block data
- Adds a block data tags expression
- Adds block -> block data converter
- Changes some variable names in ExprBlockData test
- toBlock(ItemStack): returns the item as a material, or block material
- toValidBlock(ItemStack): returns a material or null if the material wouldn't be a block
- getValue(BlockData, String): returns the value of the tag on the blockdata if it exists, or null otherwise. Also tries to convert to boolean and integer
- Adds some new examples
- Uses new toValidBlock method from BlockDataUtils
- Fixes some logic with the get and change methods
@Fusezion
Copy link
Contributor

Might be worth putting this #6087 as a related issue, I don't believe Nylhus is still working on it after about a year

Copy link
Member

@sovdeeth sovdeeth left a comment

Choose a reason for hiding this comment

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

new methods need javadocs!

@sovdeeth sovdeeth added enhancement Feature request, an issue about something that could be improved, or a PR improving something. feature Pull request adding a new feature. labels Sep 12, 2024
Copy link
Member

@sovdeeth sovdeeth left a comment

Choose a reason for hiding this comment

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

and yes this pr should have manipulation of tag support

- getValue will now try to match the value to a regex before trying to parse it as an int
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature request, an issue about something that could be improved, or a PR improving something. feature Pull request adding a new feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants