From e67501cde38be03a4915fde851544fb36a50c694 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Thu, 19 May 2022 19:54:27 +0200 Subject: [PATCH] Fix painting id being used too early Fixes #2893 --- .../viaversion/api/minecraft/entities/Entity1_19Types.java | 4 ++-- .../protocols/protocol1_19to1_18_2/packets/EntityPackets.java | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/Entity1_19Types.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/Entity1_19Types.java index fe5286512..2707e0317 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/Entity1_19Types.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/Entity1_19Types.java @@ -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; } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/EntityPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/EntityPackets.java index 1d523d56a..eaa3af942 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/EntityPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/EntityPackets.java @@ -159,8 +159,9 @@ public final class EntityPackets extends EntityRewriter { 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);