Skip to content

Handle default entity data in 1.19.3+ - #1373

Open
roccodev wants to merge 3 commits into
ViaVersion:masterfrom
roccodev:feature/default-entity-data
Open

roccodev wants to merge 3 commits into
ViaVersion:masterfrom
roccodev:feature/default-entity-data

Conversation

@roccodev

@roccodev roccodev commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1361.

I recommend viewing the diff commit-wise, the first one is the main change here and is rather simple. The second commit just integrates the default painting fix, so if you're happy with it you can also close #1315 in favor of this :)

I had a few questions/things to note though:

  • The doc comment @link in EntityReplacement is highlighted as red in intellij because the target is protected. I would like to try to keep it though as that's what most protocols will want to use
  • What are the semantics of scheduleSend? Does it always send immediately after the current packet or is it unspecified? Cause I'd like to replace the send+cancel dance in the default spawn handler with it, that way you can place the handler anywhere you'd like
  • And finally, I think we need to overwrite the first real data packet sent by the server when using spawnEntityData, but I'd like a second opinion on it, cause that's the reason why I check if there is a variant already in the painting code. I'm thinking for example, we want an invisible entity but the server entity has non-default flags so the server sends a data for index 0 on spawn, overwriting our defaults. But then again, you'd also need to make sure to handle it for the regular data packets if you care, which is what I do in Rewrite interactions as invisible slimes #1368 for example.

@roccodev roccodev changed the title Feature/default entity data Handle default entity data in 1.19.3+ Oct 24, 2026
storage.setPosition(x, y, z);
entity.put(storage);
});
handler(defaultSpawnDataHandler(ClientboundPackets1_19_3.SET_ENTITY_DATA, Types1_19_3.ENTITY_DATA_LIST));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If I understand the reasoning behind your other pr correctly, to fully close that, this should get something similar to your other handler like

mapEntityTypeWithData(EntityTypes1_19_4.PAINTING, EntityTypes1_19_4.PAINTING).spawnEntityData(data -> {
    if (!data.has(8) && data.user().getProtocolInfo().serverProtocolVersion().olderThan(ProtocolVersion.v1_21)) {
        data.add(new EntityData(8, Types1_19_3.ENTITY_DATA_TYPES.paintingVariantType, 0)); // kebab
    }
});

(untested)

@roccodev roccodev Nov 21, 2026 •

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.

Yeah you're right, I can update it in a couple days if that's ok (for those wondering, this would handle the 1.18 client on 1.19-1.21 server case where kebab would not spawn without default data)

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.

Seems to work fine on a 1.20 server. Correct me if I'm wrong, the version check should be redundant as 1.21 will apply default data before it in the pipeline (it still works with the new 1.21 default on 1.21+ servers)

@kennytv

kennytv commented Nov 21, 2026

Copy link
Copy Markdown
Member

scheduleSend on order-specific packets caused issues in the past iirc, I'd have to look deeper into that, so keeping it as is is better for now. the default spawn handler looks ok for now

@florianreuth

Copy link
Copy Markdown
Member

scheduleSend should only be used when the code isn't running inside a netty thread (e.g. when sending manual packets in bukkit events outside of the protocol code). Using it doesn't guarnatee any packet order so send+cancel is the right thing to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Default mapped entity data not respected in <1.19.3

3 participants