Package com.sk89q.worldedit.world

Examples of com.sk89q.worldedit.world.DataException


            Map<String, Tag> values = rootTag.getValue();

            Tag t = values.get("id");
            if (!(t instanceof StringTag) || !((StringTag) t).getValue().equals("Trap")) {
                throw new DataException("'Trap' tile entity expected");
            }

            List<CompoundTag> items = new ArrayList<CompoundTag>();
            for (Tag tag : NBTUtils.getChildTag(values, "Items", ListTag.class).getValue()) {
                if (!(tag instanceof CompoundTag)) {
                    throw new DataException("CompoundTag expected as child tag of Trap Items");
                }

                items.add((CompoundTag) tag);
            }
View Full Code Here


        int z = position.getBlockZ() - rootZ * 16;
        int index = y + (z * 128 + (x * 128 * 16));
        try {
            return blocks[index];
        } catch (IndexOutOfBoundsException e) {
            throw new DataException("Chunk does not contain position " + position);
        }
    }
View Full Code Here

                return (data[index] & 0xF0) >> 4;
            } else {
                return data[index] & 0xF;
            }
        } catch (IndexOutOfBoundsException e) {
            throw new DataException("Chunk does not contain position " + position);
        }
    }
View Full Code Here

                    return new TrueZipLegacyChunkStore(file);
                }

                return chunkStore;
            } catch (NoClassDefFoundError e) {
                throw new DataException("TrueZIP is required for .tar support");
            }
        } else {
            ChunkStore chunkStore = new FileMcRegionChunkStore(file);

            if (!chunkStore.isValid()) {
View Full Code Here

                try {
                    de.schlichtherle.util.zip.ZipFile entry = new de.schlichtherle.util.zip.ZipFile(file);

                    return entry.getEntry(worldname) != null;
                } catch (NoClassDefFoundError e) {
                    throw new DataException("TrueZIP is required for .tar support");
                }
            } else {
                return (file.getName().equalsIgnoreCase(worldname));
            }
        } catch (IOException ex) {
View Full Code Here

    public synchronized InputStream getChunkInputStream(Vector2D position) throws IOException, DataException {
        int x = position.getBlockX() & 31;
        int z = position.getBlockZ() & 31;

        if (x < 0 || x >= 32 || z < 0 || z >= 32) {
            throw new DataException("MCRegion file does not contain " + x + "," + z);
        }

        int offset = getOffset(x, z);

        // The chunk hasn't been generated
        if (offset == 0) {
            throw new DataException("The chunk at " + x + "," + z + " is not generated");
        }

        int sectorNumber = offset >> 8;
        int numSectors = offset & 0xFF;

        stream.seek(sectorNumber * SECTOR_BYTES);
        int length = dataStream.readInt();

        if (length > SECTOR_BYTES * numSectors) {
            throw new DataException("MCRegion chunk at "
                    + x + "," + z + " has an invalid length of " + length);
        }

        byte version = dataStream.readByte();

        if (version == VERSION_GZIP) {
            byte[] data = new byte[length - 1];
            if (dataStream.read(data) < length - 1) {
                throw new DataException("MCRegion file does not contain "
                        + x + "," + z + " in full");
            }
            return new GZIPInputStream(new ByteArrayInputStream(data));
        } else if (version == VERSION_DEFLATE) {
            byte[] data = new byte[length - 1];
            if (dataStream.read(data) < length - 1) {
                throw new DataException("MCRegion file does not contain "
                        + x + "," + z + " in full");
            }
            return new InflaterInputStream(new ByteArrayInputStream(data));
        } else {
            throw new DataException("MCRegion chunk at "
                    + x + "," + z + " has an unsupported version of " + version);
        }
    }
View Full Code Here

        int y = position.getBlockY();
        int z = position.getBlockZ() - rootZ * 16;

        int section = y >> 4;
        if (section < 0 || section >= blocks.length) {
            throw new DataException("Chunk does not contain position " + position);
        }
       
        int yindex = y & 0x0F;
        if (yindex < 0 || yindex >= 16) {
            throw new DataException("Chunk does not contain position " + position);
        }

        int index = x + (z * 16 + (yindex * 16 * 16));
       
        try {
            int addId = 0;
           
            // The block ID is the combination of the Blocks byte array with the
            // Add byte array. 'Blocks' stores the lowest 8 bits of a block's ID, and
            // 'Add' stores the highest 4 bits of the ID. The first block is stored
            // in the lowest nibble in the Add byte array.
            if (index % 2 == 0) {
                addId = (blocksAdd[section][index >> 1] & 0x0F) << 8;
            } else {
                addId = (blocksAdd[section][index >> 1] & 0xF0) << 4;
            }
           
            return (blocks[section][index] & 0xFF) + addId;
        } catch (IndexOutOfBoundsException e) {
            throw new DataException("Chunk does not contain position " + position);
        }
    }
View Full Code Here

        int section = y >> 4;
        int yIndex = y & 0x0F;
       
        if (section < 0 || section >= blocks.length) {
            throw new DataException("Chunk does not contain position " + position);
        }
       
        if (yIndex < 0 || yIndex >= 16) {
            throw new DataException("Chunk does not contain position " + position);
        }

        int index = x + (z * 16 + (yIndex * 16 * 16));
        boolean shift = index % 2 == 0;
        index /= 2;

        try {
            if (!shift) {
                return (data[section][index] & 0xF0) >> 4;
            } else {
                return data[section][index] & 0xF;
            }
        } catch (IndexOutOfBoundsException e) {
            throw new DataException("Chunk does not contain position " + position);
        }
    }
View Full Code Here

TOP

Related Classes of com.sk89q.worldedit.world.DataException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.