use of com.wuest.prefab.Capabilities.StructureConfigurationCapability 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;
}
Aggregations