Search in sources :

Example 1 with IBlueprintItem

use of buildcraft.api.items.IBlueprintItem in project BuildCraft by BuildCraft.

the class ItemBlueprint method loadBlueprint.

public static BlueprintBase loadBlueprint(ItemStack stack) {
    if (stack == null || stack.getItem() == null || !(stack.getItem() instanceof IBlueprintItem)) {
        return null;
    }
    LibraryId id = getId(stack);
    if (id == null) {
        return null;
    }
    NBTTagCompound nbt = BuildCraftBuilders.serverDB.load(id);
    BlueprintBase base;
    if (((IBlueprintItem) stack.getItem()).getType(stack) == EnumBlueprintType.TEMPLATE) {
        base = new Template();
    } else {
        base = new Blueprint();
    }
    base.readFromNBT(nbt);
    base.id = id;
    return base;
}
Also used : BlueprintBase(buildcraft.core.blueprints.BlueprintBase) LibraryId(buildcraft.core.blueprints.LibraryId) Blueprint(buildcraft.core.blueprints.Blueprint) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IBlueprintItem(buildcraft.api.items.IBlueprintItem) Template(buildcraft.core.blueprints.Template)

Aggregations

IBlueprintItem (buildcraft.api.items.IBlueprintItem)1 Blueprint (buildcraft.core.blueprints.Blueprint)1 BlueprintBase (buildcraft.core.blueprints.BlueprintBase)1 LibraryId (buildcraft.core.blueprints.LibraryId)1 Template (buildcraft.core.blueprints.Template)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1