3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-11-08 09:10:10 +01:00

Add sanity check for skullowner tag rewrite

Fixes #199
Dieser Commit ist enthalten in:
KennyTV 2020-04-17 20:47:22 +02:00
Ursprung c0668f1ee7
Commit 11417fa04e
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B

Datei anzeigen

@ -157,10 +157,8 @@ public class BlockItemPackets1_16 extends nl.matsv.viabackwards.api.rewriters.It
// Target -> target_uuid // Target -> target_uuid
UUID targetUuid = UUIDIntArrayType.uuidFromIntArray(targetUuidTag.getValue()); UUID targetUuid = UUIDIntArrayType.uuidFromIntArray(targetUuidTag.getValue());
blockEntity.put(new StringTag("target_uuid", targetUuid.toString())); blockEntity.put(new StringTag("target_uuid", targetUuid.toString()));
} else if (id.equals("minecraft:skull")) { } else if (id.equals("minecraft:skull") && blockEntity.get("SkullOwner") instanceof CompoundTag) {
CompoundTag skullOwnerTag = blockEntity.remove("SkullOwner"); CompoundTag skullOwnerTag = blockEntity.remove("SkullOwner");
if (skullOwnerTag == null) continue;
IntArrayTag ownerUuidTag = skullOwnerTag.remove("Id"); IntArrayTag ownerUuidTag = skullOwnerTag.remove("Id");
UUID ownerUuid = UUIDIntArrayType.uuidFromIntArray(ownerUuidTag.getValue()); UUID ownerUuid = UUIDIntArrayType.uuidFromIntArray(ownerUuidTag.getValue());
skullOwnerTag.put(new StringTag("Id", ownerUuid.toString())); skullOwnerTag.put(new StringTag("Id", ownerUuid.toString()));
@ -218,12 +216,13 @@ public class BlockItemPackets1_16 extends nl.matsv.viabackwards.api.rewriters.It
if (item.getIdentifier() == 771 && item.getTag() != null) { if (item.getIdentifier() == 771 && item.getTag() != null) {
CompoundTag tag = item.getTag(); CompoundTag tag = item.getTag();
CompoundTag ownerTag = tag.get("SkullOwner"); Tag ownerTag = tag.get("SkullOwner");
if (ownerTag != null) { if (ownerTag instanceof CompoundTag) {
Tag idTag = ownerTag.get("Id"); CompoundTag ownerCompundTag = (CompoundTag) ownerTag;
Tag idTag = ownerCompundTag.get("Id");
if (idTag instanceof IntArrayTag) { if (idTag instanceof IntArrayTag) {
UUID ownerUuid = UUIDIntArrayType.uuidFromIntArray((int[]) idTag.getValue()); UUID ownerUuid = UUIDIntArrayType.uuidFromIntArray((int[]) idTag.getValue());
ownerTag.put(new StringTag("Id", ownerUuid.toString())); ownerCompundTag.put(new StringTag("Id", ownerUuid.toString()));
} }
} }
} }
@ -239,12 +238,13 @@ public class BlockItemPackets1_16 extends nl.matsv.viabackwards.api.rewriters.It
if (identifier == 771 && item.getTag() != null) { if (identifier == 771 && item.getTag() != null) {
CompoundTag tag = item.getTag(); CompoundTag tag = item.getTag();
CompoundTag ownerTag = tag.get("SkullOwner"); Tag ownerTag = tag.get("SkullOwner");
if (ownerTag != null) { if (ownerTag instanceof CompoundTag) {
Tag idTag = ownerTag.get("Id"); CompoundTag ownerCompundTag = (CompoundTag) ownerTag;
Tag idTag = ownerCompundTag.get("Id");
if (idTag instanceof StringTag) { if (idTag instanceof StringTag) {
UUID ownerUuid = UUID.fromString((String) idTag.getValue()); UUID ownerUuid = UUID.fromString((String) idTag.getValue());
ownerTag.put(new IntArrayTag("Id", UUIDIntArrayType.uuidToIntArray(ownerUuid))); ownerCompundTag.put(new IntArrayTag("Id", UUIDIntArrayType.uuidToIntArray(ownerUuid)));
} }
} }
} }