Search in sources :

Example 1 with StructureConfigurationStorage

use of com.wuest.prefab.Capabilities.Storage.StructureConfigurationStorage in project MC-Prefab by Brian-Wuest.

the class ItemBasicStructure method getStackCapability.

public static IStructureConfigurationCapability getStackCapability(ItemStack stack) {
    if (stack.hasCapability(ModRegistry.StructureConfiguration, EnumFacing.NORTH)) {
        NBTTagCompound forgeCapabilities = stack.getSubCompound("ForgeCaps");
        IStructureConfigurationCapability stackCapability = stack.getCapability(ModRegistry.StructureConfiguration, EnumFacing.NORTH);
        if (forgeCapabilities != null) {
            if (stackCapability.getDirty() && forgeCapabilities.hasKey(Prefab.MODID + ":structuresconfiguration")) {
                StructureConfigurationCapability capabilityTemp = new StructureConfigurationCapability();
                StructureConfigurationStorage storage = new StructureConfigurationStorage();
                storage.readNBT(ModRegistry.StructureConfiguration, capabilityTemp, EnumFacing.NORTH, forgeCapabilities.getCompoundTag(Prefab.MODID + ":structuresconfiguration"));
                if (!capabilityTemp.getConfiguration().basicStructureName.getName().equals(stackCapability.getConfiguration().basicStructureName.getName())) {
                    stackCapability.setConfiguration(capabilityTemp.getConfiguration());
                    stackCapability.setDirty(false);
                }
            }
        }
        return stackCapability;
    }
    return null;
}
Also used : StructureConfigurationCapability(com.wuest.prefab.Capabilities.StructureConfigurationCapability) IStructureConfigurationCapability(com.wuest.prefab.Capabilities.IStructureConfigurationCapability) StructureConfigurationStorage(com.wuest.prefab.Capabilities.Storage.StructureConfigurationStorage) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IStructureConfigurationCapability(com.wuest.prefab.Capabilities.IStructureConfigurationCapability)

Aggregations

IStructureConfigurationCapability (com.wuest.prefab.Capabilities.IStructureConfigurationCapability)1 StructureConfigurationStorage (com.wuest.prefab.Capabilities.Storage.StructureConfigurationStorage)1 StructureConfigurationCapability (com.wuest.prefab.Capabilities.StructureConfigurationCapability)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1