Fix painting id being used too early

Fixes #2893
This commit is contained in:
Nassim Jahnke 2022-05-19 19:54:27 +02:00
parent 9aa7f5e879
commit e67501cde3
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
2 changed files with 4 additions and 3 deletions

View File

@ -228,7 +228,7 @@ public enum Entity1_19Types implements EntityType {
private static final EntityType[] TYPES = EntityTypeUtil.createSizedArray(values());
private final EntityType parent;
private final String identifier;
private int id;
private int id = -1;
Entity1_19Types(final EntityType parent) {
this.parent = parent;
@ -243,7 +243,7 @@ public enum Entity1_19Types implements EntityType {
@Override
public int getId() {
if (id == -1) {
throw new IllegalStateException("Ids have not been initialized yet");
throw new IllegalStateException("Ids have not been initialized yet (type " + name() + ")");
}
return id;
}

View File

@ -159,8 +159,9 @@ public final class EntityPackets extends EntityRewriter<Protocol1_19To1_18_2> {
public void registerMap() {
map(Type.VAR_INT); // Entity id
map(Type.UUID); // Entity UUID
create(Type.VAR_INT, Entity1_19Types.PAINTING.getId());
handler(wrapper -> {
wrapper.write(Type.VAR_INT, Entity1_19Types.PAINTING.getId());
final int motive = wrapper.read(Type.VAR_INT);
final Position blockPosition = wrapper.read(Type.POSITION1_14);
final byte direction = wrapper.read(Type.BYTE);