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

BlockState#copy() does not infer block entity #11700

Open
YouHaveTrouble opened this issue Dec 1, 2024 · 1 comment
Open

BlockState#copy() does not infer block entity #11700

YouHaveTrouble opened this issue Dec 1, 2024 · 1 comment
Labels
status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added. version: 1.21.3 Game version 1.21.3

Comments

@YouHaveTrouble
Copy link

Expected behavior

BlockState copy = blockState.copy(location);
copy.update(true, true)

This should set the block type and copy over all block entity data like inventories, bee data, etc.

Observed/Actual behavior

Snippet above only properly sets the block type and does not copy over the block entity data. Throws following warning Skipping BlockEntity with id.

Steps/models to reproduce

Run this snippet with any valid input as blockState and location

BlockState copy = blockState.copy(location);
copy.update(true, true)

Plugin and Datapack List

Issue occurs with only the plugin I'm testing with

Server Plugins (1):
Paper Plugins:
BlockEdit

Datapacks:
There are 3 data pack(s) enabled: [vanilla (built-in)], [file/bukkit (world)], [paper (built-in)]
There are no more data packs available

Paper version

This server is running Paper version 1.21.3-77-master@1e035f3 (2024-12-01T15:52:35Z) (Implementing API version 1.21.3-R0.1-SNAPSHOT)

Other

No response

@lynxplay
Copy link
Contributor

lynxplay commented Dec 1, 2024

TLDR rundown for anyone tackling this, the argument provider uses CraftBlockStates#getBlockState, which internally uses BlockEntity.loadStatic. That method is wrong, as the passed compound tag needs to have the BE id, which the arguments do not have to specify.

Instead, we should create the block entity if a tag is present from the blockdata/blockstate and then load from the tag.

@lynxplay lynxplay added status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added. and removed status: needs triage labels Dec 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added. version: 1.21.3 Game version 1.21.3
Projects
Status: No status
Development

No branches or pull requests

2 participants