Search in sources :

Example 1 with FMPPart

use of uk.co.qmunity.lib.part.compat.fmp.FMPPart in project BluePower by Qmunity.

the class WorldConverter method convertTile.

private boolean convertTile(NBTTagCompound tag) {
    NBTTagList parts = tag.getTagList("parts", new NBTTagCompound().getId());
    int count = parts.tagCount();
    FMPPart fmppart = new FMPPart(true);
    for (int i = 0; i < count; i++) {
        NBTTagCompound part = parts.getCompoundTagAt(i);
        String id = part.getString("id");
        for (IPartConverter c : converters) {
            if (c.matches(id)) {
                IPart p = c.convert(part);
                if (p == null)
                    continue;
                fmppart.addPart(p);
                parts.removeTag(i);
                i--;
                break;
            }
        }
        count = parts.tagCount();
    }
    if (fmppart.getParts().size() > 0) {
        NBTTagCompound part = new NBTTagCompound();
        fmppart.save(part);
        part.setString("id", fmppart.getType());
        parts.appendTag(part);
        return true;
    }
    return false;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) IPart(uk.co.qmunity.lib.part.IPart) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) FMPPart(uk.co.qmunity.lib.part.compat.fmp.FMPPart)

Aggregations

NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 NBTTagList (net.minecraft.nbt.NBTTagList)1 IPart (uk.co.qmunity.lib.part.IPart)1 FMPPart (uk.co.qmunity.lib.part.compat.fmp.FMPPart)1