use of com.github.steveice10.opennbt.tag.builtin.IntArrayTag in project ViaVersion by ViaVersion.
the class InventoryPackets method oldToNewAttributes.
public static void oldToNewAttributes(Item item) {
if (item.tag() == null)
return;
ListTag attributes = item.tag().get("AttributeModifiers");
if (attributes == null)
return;
for (Tag tag : attributes) {
CompoundTag attribute = (CompoundTag) tag;
rewriteAttributeName(attribute, "AttributeName", false);
rewriteAttributeName(attribute, "Name", false);
Tag leastTag = attribute.get("UUIDLeast");
if (leastTag != null) {
Tag mostTag = attribute.get("UUIDMost");
int[] uuidIntArray = UUIDIntArrayType.bitsToIntArray(((NumberTag) leastTag).asLong(), ((NumberTag) mostTag).asLong());
attribute.put("UUID", new IntArrayTag(uuidIntArray));
}
}
}
use of com.github.steveice10.opennbt.tag.builtin.IntArrayTag in project ViaVersion by ViaVersion.
the class InventoryPackets method handleItemToClient.
@Override
public Item handleItemToClient(Item item) {
if (item == null)
return null;
if (item.identifier() == 771 && item.tag() != null) {
CompoundTag tag = item.tag();
Tag ownerTag = tag.get("SkullOwner");
if (ownerTag instanceof CompoundTag) {
CompoundTag ownerCompundTag = (CompoundTag) ownerTag;
Tag idTag = ownerCompundTag.get("Id");
if (idTag instanceof StringTag) {
UUID id = UUID.fromString((String) idTag.getValue());
ownerCompundTag.put("Id", new IntArrayTag(UUIDIntArrayType.uuidToIntArray(id)));
}
}
}
oldToNewAttributes(item);
item.setIdentifier(Protocol1_16To1_15_2.MAPPINGS.getNewItemId(item.identifier()));
return item;
}
use of com.github.steveice10.opennbt.tag.builtin.IntArrayTag in project DragonProxy by DragonetMC.
the class ItemBlockTranslator method translateRawNBT.
@SuppressWarnings("unchecked")
public static org.dragonet.common.data.nbt.tag.CompoundTag translateRawNBT(int id, Tag pcTag, org.dragonet.common.data.nbt.tag.CompoundTag target) {
if (pcTag != null) {
String name = pcTag.getName() != null ? pcTag.getName() : "";
if (target == null)
target = new org.dragonet.common.data.nbt.tag.CompoundTag(name);
switch(pcTag.getClass().getSimpleName()) {
case "ByteArrayTag":
target.putByteArray(name, (byte[]) pcTag.getValue());
break;
case "ByteTag":
target.putByte(name, (byte) pcTag.getValue());
break;
case "DoubleTag":
target.putDouble(name, (double) pcTag.getValue());
break;
case "FloatTag":
target.putFloat(name, (float) pcTag.getValue());
break;
case "IntArrayTag":
target.putIntArray(name, (int[]) pcTag.getValue());
break;
case "IntTag":
target.putInt(name, (int) pcTag.getValue());
break;
case "LongTag":
target.putLong(name, (long) pcTag.getValue());
break;
case "ShortTag":
target.putShort(name, (short) pcTag.getValue());
break;
case "StringTag":
target.putString(name, (String) pcTag.getValue());
break;
case "CompoundTag":
for (String subName : ((CompoundTag) pcTag).getValue().keySet()) translateRawNBT(0, ((CompoundTag) pcTag).getValue().get(subName), target);
break;
case "ListTag":
ListTag listTag = new ListTag();
for (Tag subTag : (List<Tag>) pcTag.getValue()) listTag.add(translateRawNBT(0, subTag, new org.dragonet.common.data.nbt.tag.CompoundTag()));
target.putList(listTag);
break;
default:
System.out.println("TAG not implemented : " + pcTag.getClass().getSimpleName());
break;
}
}
return target;
}
use of com.github.steveice10.opennbt.tag.builtin.IntArrayTag in project ViaVersion by ViaVersion.
the class WorldPackets method handleBlockEntity.
private static void handleBlockEntity(CompoundTag compoundTag) {
StringTag idTag = compoundTag.get("id");
if (idTag == null)
return;
String id = idTag.getValue();
if (id.equals("minecraft:conduit")) {
Tag targetUuidTag = compoundTag.remove("target_uuid");
if (!(targetUuidTag instanceof StringTag))
return;
// target_uuid -> Target
UUID targetUuid = UUID.fromString((String) targetUuidTag.getValue());
compoundTag.put("Target", new IntArrayTag(UUIDIntArrayType.uuidToIntArray(targetUuid)));
} else if (id.equals("minecraft:skull") && compoundTag.get("Owner") instanceof CompoundTag) {
CompoundTag ownerTag = compoundTag.remove("Owner");
StringTag ownerUuidTag = ownerTag.remove("Id");
if (ownerUuidTag != null) {
UUID ownerUuid = UUID.fromString(ownerUuidTag.getValue());
ownerTag.put("Id", new IntArrayTag(UUIDIntArrayType.uuidToIntArray(ownerUuid)));
}
// Owner -> SkullOwner
CompoundTag skullOwnerTag = new CompoundTag();
for (Map.Entry<String, Tag> entry : ownerTag.entrySet()) {
skullOwnerTag.put(entry.getKey(), entry.getValue());
}
compoundTag.put("SkullOwner", skullOwnerTag);
}
}
Aggregations