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

Getting sign lines from block break event returns null #2416

Open
tyhdefu opened this issue Nov 9, 2019 · 2 comments
Open

Getting sign lines from block break event returns null #2416

tyhdefu opened this issue Nov 9, 2019 · 2 comments
Labels
status: pr pending A PR was opened to fix this issue system: data type: bug Something isn't working version: 1.12 (u) API: 7 (unsupported since May 21st 2021)

Comments

@tyhdefu
Copy link
Contributor

tyhdefu commented Nov 9, 2019

In a break block event, I try to get the data of a sign, I check if its a wall sign, it is, so it continues, pastes all of the sign data into console:
[13:19:50 WARN] [test]: {"ContentVersion":1,"WorldUuid":"0e8d1aa1-f7db-411b-b732-7027b0444aa9","Position":{"X":549,"Y":82,"Z":-45},"BlockState":{"ContentVersion":2,"BlockState":"minecraft:wall_sign[facing=south]"},"UnsafeData":{"x":549,"Text4":"{\"text\":\"defutyh\"}","y":82,"Text3":"{\"text\":\"dirt 10\"}","z":-45,"Text2":"{\"text\":\"stone 1\"}","id":"minecraft:sign","Text1":"{\"text\":\"[Shop]\"}"}}

Yet when I try to retrieve the data using keys, it gives a no such element exception. I would expect it to return the first sign line to console.

for ( Transaction<BlockSnapshot> block : event.getTransactions())
{
    if (!block.getOriginal().getState().getType().equals(BlockTypes.WALL_SIGN))
    {
        continue;
    }
    logger.warn(DataFormats.JSON.write(block.getOriginal().toContainer()));
    logger.warn(block.getOriginal().get(Keys.SIGN_LINES).get().get(0).toPlain());
}

To reproduce:
Add this code to the block break event listener,
Go into the server and break a sign, should get an error in console.

SpongeVanilla 1.12.2

@ImMorpheus ImMorpheus transferred this issue from SpongePowered/SpongeAPI Nov 9, 2019
@JBYoshi JBYoshi added status: accepted a confirmation that this is either an issue caused by us or something that should be added system: data type: bug Something isn't working version: 1.12 (u) API: 7 (unsupported since May 21st 2021) labels Nov 17, 2019
@JBYoshi
Copy link
Member

JBYoshi commented Nov 17, 2019

I can reproduce this on SpongeForge RC3950.

@JBYoshi
Copy link
Member

JBYoshi commented Nov 17, 2019

Will be fixed by #1905.

@JBYoshi JBYoshi added status: pr pending A PR was opened to fix this issue and removed status: accepted a confirmation that this is either an issue caused by us or something that should be added labels Nov 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: pr pending A PR was opened to fix this issue system: data type: bug Something isn't working version: 1.12 (u) API: 7 (unsupported since May 21st 2021)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants