use of com.viaversion.viaversion.libs.opennbt.tag.builtin.IntArrayTag in project ViaBackwards by ViaVersion.
the class BlockItemPackets1_16 method handleItemToServer.
@Override
public Item handleItemToServer(Item item) {
if (item == null)
return null;
int identifier = item.identifier();
super.handleItemToServer(item);
CompoundTag tag = item.tag();
if (identifier == 771 && tag != null) {
Tag ownerTag = tag.get("SkullOwner");
if (ownerTag instanceof CompoundTag) {
CompoundTag ownerCompundTag = (CompoundTag) ownerTag;
Tag idTag = ownerCompundTag.get("Id");
if (idTag instanceof StringTag) {
UUID ownerUuid = UUID.fromString((String) idTag.getValue());
ownerCompundTag.put("Id", new IntArrayTag(UUIDIntArrayType.uuidToIntArray(ownerUuid)));
}
}
}
InventoryPackets.oldToNewAttributes(item);
enchantmentRewriter.handleToServer(item);
return item;
}
use of com.viaversion.viaversion.libs.opennbt.tag.builtin.IntArrayTag in project ViaBackwards by ViaVersion.
the class BlockItemPackets1_12 method handleNbtToServer.
private void handleNbtToServer(CompoundTag compoundTag, CompoundTag backupTag) {
// Restore the removed long array tags
for (Map.Entry<String, Tag> entry : backupTag) {
if (entry.getValue() instanceof CompoundTag) {
CompoundTag nestedTag = compoundTag.get(entry.getKey());
handleNbtToServer(nestedTag, (CompoundTag) entry.getValue());
} else {
compoundTag.put(entry.getKey(), fromIntArrayTag((IntArrayTag) entry.getValue()));
}
}
}
use of com.viaversion.viaversion.libs.opennbt.tag.builtin.IntArrayTag in project ViaBackwards by ViaVersion.
the class BlockItemPackets1_16_2 method handleBlockEntity.
private void handleBlockEntity(CompoundTag tag) {
StringTag idTag = tag.get("id");
if (idTag == null)
return;
if (idTag.getValue().equals("minecraft:skull")) {
// Workaround an old client bug: MC-68487
Tag skullOwnerTag = tag.get("SkullOwner");
if (!(skullOwnerTag instanceof CompoundTag))
return;
CompoundTag skullOwnerCompoundTag = (CompoundTag) skullOwnerTag;
if (!skullOwnerCompoundTag.contains("Id"))
return;
CompoundTag properties = skullOwnerCompoundTag.get("Properties");
if (properties == null)
return;
ListTag textures = properties.get("textures");
if (textures == null)
return;
CompoundTag first = textures.size() > 0 ? textures.get(0) : null;
if (first == null)
return;
// Make the client cache the skinprofile over this uuid
int hashCode = first.get("Value").getValue().hashCode();
// TODO split texture in 4 for a lower collision chance
int[] uuidIntArray = { hashCode, 0, 0, 0 };
skullOwnerCompoundTag.put("Id", new IntArrayTag(uuidIntArray));
}
}
use of com.viaversion.viaversion.libs.opennbt.tag.builtin.IntArrayTag in project ViaBackwards by ViaVersion.
the class BlockItemPackets1_16 method handleBlockEntity.
private void handleBlockEntity(CompoundTag tag) {
StringTag idTag = tag.get("id");
if (idTag == null)
return;
String id = idTag.getValue();
if (id.equals("minecraft:conduit")) {
Tag targetUuidTag = tag.remove("Target");
if (!(targetUuidTag instanceof IntArrayTag))
return;
// Target -> target_uuid
UUID targetUuid = UUIDIntArrayType.uuidFromIntArray((int[]) targetUuidTag.getValue());
tag.put("target_uuid", new StringTag(targetUuid.toString()));
} else if (id.equals("minecraft:skull")) {
Tag skullOwnerTag = tag.remove("SkullOwner");
if (!(skullOwnerTag instanceof CompoundTag))
return;
CompoundTag skullOwnerCompoundTag = (CompoundTag) skullOwnerTag;
Tag ownerUuidTag = skullOwnerCompoundTag.remove("Id");
if (ownerUuidTag instanceof IntArrayTag) {
UUID ownerUuid = UUIDIntArrayType.uuidFromIntArray((int[]) ownerUuidTag.getValue());
skullOwnerCompoundTag.put("Id", new StringTag(ownerUuid.toString()));
}
// SkullOwner -> Owner
CompoundTag ownerTag = new CompoundTag();
for (Map.Entry<String, Tag> entry : skullOwnerCompoundTag) {
ownerTag.put(entry.getKey(), entry.getValue());
}
tag.put("Owner", ownerTag);
}
}
use of com.viaversion.viaversion.libs.opennbt.tag.builtin.IntArrayTag in project ViaBackwards by ViaVersion.
the class BlockItemPackets1_16 method handleItemToClient.
@Override
public Item handleItemToClient(Item item) {
if (item == null)
return null;
super.handleItemToClient(item);
CompoundTag tag = item.tag();
if (item.identifier() == 771 && tag != null) {
Tag ownerTag = tag.get("SkullOwner");
if (ownerTag instanceof CompoundTag) {
CompoundTag ownerCompundTag = (CompoundTag) ownerTag;
Tag idTag = ownerCompundTag.get("Id");
if (idTag instanceof IntArrayTag) {
UUID ownerUuid = UUIDIntArrayType.uuidFromIntArray((int[]) idTag.getValue());
ownerCompundTag.put("Id", new StringTag(ownerUuid.toString()));
}
}
}
InventoryPackets.newToOldAttributes(item);
enchantmentRewriter.handleToClient(item);
return item;
}
Aggregations