use of com.sk89q.worldedit.world.storage.InvalidFormatException in project FastAsyncWorldEdit by IntellectualSites.
the class AnvilChunk method populateTileEntities.
/**
* Used to load the tile entities.
*/
private void populateTileEntities() throws DataException {
ListBinaryTag tags = NbtUtils.getChildTag(rootTag, "TileEntities", BinaryTagTypes.LIST);
tileEntities = new HashMap<>();
for (BinaryTag tag : tags) {
if (!(tag instanceof CompoundBinaryTag)) {
throw new InvalidFormatException("CompoundTag expected in TileEntities");
}
CompoundBinaryTag t = (CompoundBinaryTag) tag;
int x = 0;
int y = 0;
int z = 0;
CompoundBinaryTag.Builder values = CompoundBinaryTag.builder();
for (String key : t.keySet()) {
BinaryTag value = t.get(key);
switch(key) {
case "x":
if (value instanceof IntBinaryTag) {
x = ((IntBinaryTag) value).value();
}
break;
case "y":
if (value instanceof IntBinaryTag) {
y = ((IntBinaryTag) value).value();
}
break;
case "z":
if (value instanceof IntBinaryTag) {
z = ((IntBinaryTag) value).value();
}
break;
default:
break;
}
values.put(key, value);
}
BlockVector3 vec = BlockVector3.at(x, y, z);
tileEntities.put(vec, values.build());
}
}
use of com.sk89q.worldedit.world.storage.InvalidFormatException in project FastAsyncWorldEdit by IntellectualSites.
the class AnvilChunk13 method populateTileEntities.
/**
* Used to load the tile entities.
*/
private void populateTileEntities() throws DataException {
tileEntities = new HashMap<>();
if (rootTag.get("TileEntities") == null) {
return;
}
ListBinaryTag tags = NbtUtils.getChildTag(rootTag, "TileEntities", BinaryTagTypes.LIST);
for (BinaryTag tag : tags) {
if (!(tag instanceof CompoundBinaryTag)) {
throw new InvalidFormatException("CompoundTag expected in TileEntities");
}
CompoundBinaryTag t = (CompoundBinaryTag) tag;
int x = ((IntBinaryTag) t.get("x")).value();
int y = ((IntBinaryTag) t.get("y")).value();
int z = ((IntBinaryTag) t.get("z")).value();
BlockVector3 vec = BlockVector3.at(x, y, z);
tileEntities.put(vec, t);
}
}
Aggregations