Search in sources :

Example 1 with ICustomModule

use of mekanism.api.gear.ICustomModule in project Mekanism by mekanism.

the class ModuleHelper method loadAll.

@Override
public <MODULE extends ICustomModule<?>> List<Module<? extends MODULE>> loadAll(ItemStack container, Class<MODULE> moduleClass) {
    if (container.getItem() instanceof IModuleContainerItem) {
        List<Module<? extends MODULE>> modules = new ArrayList<>();
        CompoundNBT modulesTag = ItemDataUtils.getCompound(container, NBTConstants.MODULES);
        for (ModuleData<?> moduleType : loadAllTypes(modulesTag)) {
            Module<?> module = load(container, moduleType, modulesTag, moduleClass);
            if (module != null) {
                modules.add((Module<? extends MODULE>) module);
            }
        }
        return modules;
    }
    return Collections.emptyList();
}
Also used : CompoundNBT(net.minecraft.nbt.CompoundNBT) ArrayList(java.util.ArrayList) ICustomModule(mekanism.api.gear.ICustomModule) IModule(mekanism.api.gear.IModule) ItemModule(mekanism.common.item.ItemModule)

Aggregations

ArrayList (java.util.ArrayList)1 ICustomModule (mekanism.api.gear.ICustomModule)1 IModule (mekanism.api.gear.IModule)1 ItemModule (mekanism.common.item.ItemModule)1 CompoundNBT (net.minecraft.nbt.CompoundNBT)1