use of net.minecraft.nbt.NBTTagCompound in project BluePower by Qmunity.
the class WorldConverter method convertRegion.
private void convertRegion(File file) {
RegionFile reg = new RegionFile(file);
for (int x = 0; x < 32; x++) {
for (int z = 0; z < 32; z++) {
NBTTagCompound chunk = getChunk(reg, x, z);
if (chunk == null)
continue;
NBTTagList tileEntities = chunk.getTagList("TileEntities", new NBTTagCompound().getId());
boolean changed = false;
for (int i = 0; i < tileEntities.tagCount(); i++) {
NBTTagCompound te = tileEntities.getCompoundTagAt(i);
if (te.getString("id").equals("savedMultipart"))
changed |= convertTile(te);
}
if (changed)
saveChunk(reg, x, z, chunk);
}
}
try {
reg.close();
} catch (IOException e) {
e.printStackTrace();
}
}
use of net.minecraft.nbt.NBTTagCompound in project BluePower by Qmunity.
the class WorldConverter method getChunk.
private NBTTagCompound getChunk(RegionFile reg, int x, int y) {
try {
DataInputStream inputStream = reg.getChunkDataInputStream(x & 31, y & 31);
if (inputStream == null)
return null;
NBTTagCompound tag = CompressedStreamTools.read(inputStream).getCompoundTag("Level");
return tag;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
use of net.minecraft.nbt.NBTTagCompound in project BluePower by Qmunity.
the class WorldConverter method saveChunk.
private void saveChunk(RegionFile reg, int x, int y, NBTTagCompound chunkData) {
NBTTagCompound tag = new NBTTagCompound();
tag.setTag("Level", chunkData);
try {
DataOutputStream outputStream = reg.getChunkDataOutputStream(x & 31, y & 31);
CompressedStreamTools.write(tag, outputStream);
outputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
use of net.minecraft.nbt.NBTTagCompound in project BluePower by Qmunity.
the class PartConverterWire method convert.
@Override
public IPart convert(NBTTagCompound old) {
String id = old.getString("part_id").replace("bluestoneWire", "wire.bluestone").replace("silver", "light_gray");
PartInfo info = PartManager.getPartInfo(id);
if (info == null)
return null;
PartRedwireFace part = (PartRedwireFace) info.create();
NBTTagCompound data = old.getCompoundTag("partData");
part.setFace(ForgeDirection.getOrientation(data.getInteger("face")));
return part;
}
use of net.minecraft.nbt.NBTTagCompound in project BluePower by Qmunity.
the class GateIntegratedCircuit method readParts.
private void readParts(NBTTagList l) {
for (int i = 0; i < l.tagCount(); i++) {
NBTTagCompound tag = l.getCompoundTagAt(i);
int x = tag.getInteger("x");
int z = tag.getInteger("z");
IPart p = getPart(x, z);
if (p == null) {
p = PartRegistry.createPart(tag.getString("type"), false);
if (p == null || !(p instanceof IIntegratedCircuitPart))
continue;
setPart(x, z, (IIntegratedCircuitPart) p);
}
p.readFromNBT(tag.getCompoundTag("data"));
}
}
Aggregations