Search in sources :

Example 1 with NBTList

use of io.xol.enklume.nbt.NBTList in project chunkstories-core by Hugobros3.

the class Sign method translateSignText.

private void translateSignText(VoxelComponent target, MinecraftChunk minecraftChunk, int x, int y, int z) {
    NBTCompound root = minecraftChunk.getRootTag();
    if (root == null)
        return;
    NBTList entitiesList = (NBTList) root.getTag("Level.TileEntities");
    // Check it exists and is of the right kind
    if (target != null && target instanceof VoxelComponentSignText) {
        VoxelComponentSignText signTextComponent = (VoxelComponentSignText) target;
        signTextComponent.setSignText("<corresponding sign not found :(>");
        for (NBTag element : entitiesList.elements) {
            NBTCompound entity = (NBTCompound) element;
            NBTString entityId = (NBTString) entity.getTag("id");
            int tileX = ((NBTInt) entity.getTag("x")).data;
            int tileY = ((NBTInt) entity.getTag("y")).data;
            int tileZ = ((NBTInt) entity.getTag("z")).data;
            if (entityId.data.toLowerCase().equals("sign") || entityId.data.toLowerCase().equals("minecraft:sign")) {
                // System.out.println("Looking up sign data for B:"+x+":"+y+":"+z);
                if ((tileX & 0xF) != x || tileY != y || (tileZ & 0xF) != z) {
                    continue;
                }
                String text1 = SignParseUtil.parseSignData(((NBTString) entity.getTag("Text1")).data);
                String text2 = SignParseUtil.parseSignData(((NBTString) entity.getTag("Text2")).data);
                String text3 = SignParseUtil.parseSignData(((NBTString) entity.getTag("Text3")).data);
                String text4 = SignParseUtil.parseSignData(((NBTString) entity.getTag("Text4")).data);
                String textComplete = text1 + "\n" + text2 + "\n" + text3 + "\n" + text4;
                signTextComponent.setSignText(textComplete);
                System.out.println("OK: " + textComplete);
                break;
            // ((EntitySign) ((VoxelSign) voxel).getEntity(exported.peekSafely(csCoordinatesX, csCoordinatesY, csCoordinatesZ))).setText(textComplete);
            }
        // else
        // System.out.println("Found "+entityId.data);
        }
    }
}
Also used : VoxelComponentSignText(io.xol.chunkstories.core.voxel.components.VoxelComponentSignText) NBTList(io.xol.enklume.nbt.NBTList) NBTCompound(io.xol.enklume.nbt.NBTCompound) NBTString(io.xol.enklume.nbt.NBTString) NBTag(io.xol.enklume.nbt.NBTag) NBTString(io.xol.enklume.nbt.NBTString) NBTInt(io.xol.enklume.nbt.NBTInt)

Aggregations

VoxelComponentSignText (io.xol.chunkstories.core.voxel.components.VoxelComponentSignText)1 NBTCompound (io.xol.enklume.nbt.NBTCompound)1 NBTInt (io.xol.enklume.nbt.NBTInt)1 NBTList (io.xol.enklume.nbt.NBTList)1 NBTString (io.xol.enklume.nbt.NBTString)1 NBTag (io.xol.enklume.nbt.NBTag)1