Search in sources :

Example 1 with ChunkImpl2

use of org.pepsoft.minecraft.ChunkImpl2 in project WorldPainter by Captain-Chaos.

the class DumpEntities method main.

public static void main(String[] args) throws IOException {
    File worldDir = new File(args[0]);
    File[] regionFiles = new File(worldDir, "region").listFiles();
    for (File file : regionFiles) {
        RegionFile regionFile = new RegionFile(file);
        try {
            for (int x = 0; x < 32; x++) {
                for (int z = 0; z < 32; z++) {
                    if (regionFile.containsChunk(x, z)) {
                        CompoundTag tag;
                        try (NBTInputStream in = new NBTInputStream(regionFile.getChunkDataInputStream(x, z))) {
                            tag = (CompoundTag) in.readTag();
                        }
                        ChunkImpl2 chunk = new ChunkImpl2(tag, 256);
                        /*&& (((Painting) entity).getTileX() == 40) && (((Painting) entity).getTileZ() == 31)*/
                        chunk.getEntities().stream().filter(entity -> (entity instanceof Painting)).forEach(System.out::println);
                    }
                }
            }
        } finally {
            regionFile.close();
        }
    }
}
Also used : NBTInputStream(org.jnbt.NBTInputStream) Painting(org.pepsoft.minecraft.Painting) CompoundTag(org.jnbt.CompoundTag) ChunkImpl2(org.pepsoft.minecraft.ChunkImpl2) IOException(java.io.IOException) File(java.io.File) RegionFile(org.pepsoft.minecraft.RegionFile) RegionFile(org.pepsoft.minecraft.RegionFile) NBTInputStream(org.jnbt.NBTInputStream) File(java.io.File) RegionFile(org.pepsoft.minecraft.RegionFile) CompoundTag(org.jnbt.CompoundTag) ChunkImpl2(org.pepsoft.minecraft.ChunkImpl2) Painting(org.pepsoft.minecraft.Painting)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 CompoundTag (org.jnbt.CompoundTag)1 NBTInputStream (org.jnbt.NBTInputStream)1 ChunkImpl2 (org.pepsoft.minecraft.ChunkImpl2)1 Painting (org.pepsoft.minecraft.Painting)1 RegionFile (org.pepsoft.minecraft.RegionFile)1