Search in sources :

Example 1 with LongTag

use of com.github.steveice10.opennbt.tag.builtin.LongTag in project Geyser by GeyserMC.

the class EndGatewayBlockEntityTranslator method translateTag.

@Override
public void translateTag(NbtMapBuilder builder, CompoundTag tag, int blockState) {
    Tag ageTag = tag.get("Age");
    if (ageTag instanceof LongTag) {
        builder.put("Age", (int) ((long) ageTag.getValue()));
    }
    // Java sometimes does not provide this tag, but Bedrock crashes if it doesn't exist
    // Linked coordinates
    IntList tagsList = new IntArrayList();
    // Yes, the axis letters are capitalized
    tagsList.add(getExitPortalCoordinate(tag, "X"));
    tagsList.add(getExitPortalCoordinate(tag, "Y"));
    tagsList.add(getExitPortalCoordinate(tag, "Z"));
    builder.put("ExitPortal", new NbtList<>(NbtType.INT, tagsList));
}
Also used : Tag(com.github.steveice10.opennbt.tag.builtin.Tag) LongTag(com.github.steveice10.opennbt.tag.builtin.LongTag) CompoundTag(com.github.steveice10.opennbt.tag.builtin.CompoundTag) IntTag(com.github.steveice10.opennbt.tag.builtin.IntTag) IntArrayList(it.unimi.dsi.fastutil.ints.IntArrayList) LongTag(com.github.steveice10.opennbt.tag.builtin.LongTag) IntList(it.unimi.dsi.fastutil.ints.IntList)

Example 2 with LongTag

use of com.github.steveice10.opennbt.tag.builtin.LongTag in project ViaVersion by ViaVersion.

the class InventoryPackets method newToOldAttributes.

public static void newToOldAttributes(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", true);
        rewriteAttributeName(attribute, "Name", true);
        IntArrayTag uuidTag = attribute.get("UUID");
        if (uuidTag != null && uuidTag.getValue().length == 4) {
            UUID uuid = UUIDIntArrayType.uuidFromIntArray(uuidTag.getValue());
            attribute.put("UUIDLeast", new LongTag(uuid.getLeastSignificantBits()));
            attribute.put("UUIDMost", new LongTag(uuid.getMostSignificantBits()));
        }
    }
}
Also used : IntArrayTag(com.github.steveice10.opennbt.tag.builtin.IntArrayTag) ListTag(com.github.steveice10.opennbt.tag.builtin.ListTag) IntArrayTag(com.github.steveice10.opennbt.tag.builtin.IntArrayTag) NumberTag(com.github.steveice10.opennbt.tag.builtin.NumberTag) StringTag(com.github.steveice10.opennbt.tag.builtin.StringTag) Tag(com.github.steveice10.opennbt.tag.builtin.Tag) LongTag(com.github.steveice10.opennbt.tag.builtin.LongTag) CompoundTag(com.github.steveice10.opennbt.tag.builtin.CompoundTag) UUID(java.util.UUID) ListTag(com.github.steveice10.opennbt.tag.builtin.ListTag) CompoundTag(com.github.steveice10.opennbt.tag.builtin.CompoundTag) LongTag(com.github.steveice10.opennbt.tag.builtin.LongTag)

Example 3 with LongTag

use of com.github.steveice10.opennbt.tag.builtin.LongTag in project ViaVersion by ViaVersion.

the class EntityPackets method createEndEntry.

private static CompoundTag createEndEntry() {
    CompoundTag tag = new CompoundTag();
    tag.put("piglin_safe", new ByteTag((byte) 0));
    tag.put("natural", new ByteTag((byte) 0));
    tag.put("ambient_light", new FloatTag(0));
    tag.put("infiniburn", new StringTag("minecraft:infiniburn_end"));
    tag.put("respawn_anchor_works", new ByteTag((byte) 0));
    tag.put("has_skylight", new ByteTag((byte) 0));
    tag.put("bed_works", new ByteTag((byte) 0));
    tag.put("fixed_time", new LongTag(6000));
    tag.put("has_raids", new ByteTag((byte) 1));
    tag.put("name", new StringTag("minecraft:the_end"));
    tag.put("logical_height", new IntTag(256));
    tag.put("shrunk", new ByteTag((byte) 0));
    tag.put("ultrawarm", new ByteTag((byte) 0));
    tag.put("has_ceiling", new ByteTag((byte) 0));
    return tag;
}
Also used : StringTag(com.github.steveice10.opennbt.tag.builtin.StringTag) FloatTag(com.github.steveice10.opennbt.tag.builtin.FloatTag) ByteTag(com.github.steveice10.opennbt.tag.builtin.ByteTag) CompoundTag(com.github.steveice10.opennbt.tag.builtin.CompoundTag) IntTag(com.github.steveice10.opennbt.tag.builtin.IntTag) LongTag(com.github.steveice10.opennbt.tag.builtin.LongTag)

Example 4 with LongTag

use of com.github.steveice10.opennbt.tag.builtin.LongTag 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;
}
Also used : List(java.util.List) IntTag(com.github.steveice10.opennbt.tag.builtin.IntTag) StringTag(com.github.steveice10.opennbt.tag.builtin.StringTag) ListTag(org.dragonet.common.data.nbt.tag.ListTag) Tag(com.github.steveice10.opennbt.tag.builtin.Tag) CompoundTag(com.github.steveice10.opennbt.tag.builtin.CompoundTag) ListTag(org.dragonet.common.data.nbt.tag.ListTag) CompoundTag(com.github.steveice10.opennbt.tag.builtin.CompoundTag)

Example 5 with LongTag

use of com.github.steveice10.opennbt.tag.builtin.LongTag in project ViaVersion by ViaVersion.

the class EntityPackets method createNetherEntry.

private static CompoundTag createNetherEntry() {
    CompoundTag tag = new CompoundTag();
    tag.put("piglin_safe", new ByteTag((byte) 1));
    tag.put("natural", new ByteTag((byte) 0));
    tag.put("ambient_light", new FloatTag(0.1F));
    tag.put("infiniburn", new StringTag("minecraft:infiniburn_nether"));
    tag.put("respawn_anchor_works", new ByteTag((byte) 1));
    tag.put("has_skylight", new ByteTag((byte) 0));
    tag.put("bed_works", new ByteTag((byte) 0));
    tag.put("fixed_time", new LongTag(18000));
    tag.put("has_raids", new ByteTag((byte) 0));
    tag.put("name", new StringTag("minecraft:the_nether"));
    tag.put("logical_height", new IntTag(128));
    tag.put("shrunk", new ByteTag((byte) 1));
    tag.put("ultrawarm", new ByteTag((byte) 1));
    tag.put("has_ceiling", new ByteTag((byte) 1));
    return tag;
}
Also used : StringTag(com.github.steveice10.opennbt.tag.builtin.StringTag) FloatTag(com.github.steveice10.opennbt.tag.builtin.FloatTag) ByteTag(com.github.steveice10.opennbt.tag.builtin.ByteTag) CompoundTag(com.github.steveice10.opennbt.tag.builtin.CompoundTag) IntTag(com.github.steveice10.opennbt.tag.builtin.IntTag) LongTag(com.github.steveice10.opennbt.tag.builtin.LongTag)

Aggregations

CompoundTag (com.github.steveice10.opennbt.tag.builtin.CompoundTag)5 IntTag (com.github.steveice10.opennbt.tag.builtin.IntTag)5 LongTag (com.github.steveice10.opennbt.tag.builtin.LongTag)5 StringTag (com.github.steveice10.opennbt.tag.builtin.StringTag)5 ByteTag (com.github.steveice10.opennbt.tag.builtin.ByteTag)3 FloatTag (com.github.steveice10.opennbt.tag.builtin.FloatTag)3 Tag (com.github.steveice10.opennbt.tag.builtin.Tag)3 DoubleTag (com.github.steveice10.opennbt.tag.builtin.DoubleTag)1 IntArrayTag (com.github.steveice10.opennbt.tag.builtin.IntArrayTag)1 ListTag (com.github.steveice10.opennbt.tag.builtin.ListTag)1 NumberTag (com.github.steveice10.opennbt.tag.builtin.NumberTag)1 ShortTag (com.github.steveice10.opennbt.tag.builtin.ShortTag)1 IntArrayList (it.unimi.dsi.fastutil.ints.IntArrayList)1 IntList (it.unimi.dsi.fastutil.ints.IntList)1 List (java.util.List)1 UUID (java.util.UUID)1 ListTag (org.dragonet.common.data.nbt.tag.ListTag)1