Skip to content

Commit c6cde5f

Browse files
Cancel unknown block entities in BlockRewriter#registerBlockEntityData (ViaVersion#4466)
1 parent bf84eb0 commit c6cde5f

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

common/src/main/java/com/viaversion/viaversion/rewriter/BlockRewriter.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,12 @@ public void registerBlockEntityData(C packetType, @Nullable BiConsumer<UserConne
268268
final int blockEntityId = wrapper.read(Types.VAR_INT);
269269
final Mappings mappings = protocol.getMappingData().getBlockEntityMappings();
270270
if (mappings != null) {
271-
wrapper.write(Types.VAR_INT, mappings.getNewIdOrDefault(blockEntityId, blockEntityId));
271+
final int mappedBlockEntityId = mappings.getNewId(blockEntityId);
272+
if (mappedBlockEntityId == -1) {
273+
wrapper.cancel();
274+
return;
275+
}
276+
wrapper.write(Types.VAR_INT, mappedBlockEntityId);
272277
} else {
273278
wrapper.write(Types.VAR_INT, blockEntityId);
274279
}

common/src/main/java/com/viaversion/viaversion/util/SerializerVersion.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public enum SerializerVersion {
5050
V1_20_3(TextComponentCodec.V1_20_3, SNbt.V1_14),
5151
V1_20_5(TextComponentCodec.V1_20_5, SNbt.V1_14),
5252
V1_21_4(TextComponentCodec.V1_21_4, SNbt.V1_14),
53-
V1_21_5(TextComponentCodec.V1_21_5, SNbt.V1_21_5);
53+
V1_21_5(TextComponentCodec.V1_21_5, null/*Currently not needed and also not implemented 100% in MCStructs*/);
5454

5555
final TextComponentSerializer jsonSerializer;
5656
final SNbt<? extends Tag> sNbt;

0 commit comments

Comments
 (0)