Search in sources :

Example 1 with SlurryRecipeData

use of mekanism.common.recipe.upgrade.chemical.SlurryRecipeData in project Mekanism by mekanism.

the class RecipeUpgradeData method getUpgradeData.

/**
 * Make sure to validate with getSupportedTypes before calling this
 */
@Nullable
static RecipeUpgradeData<?> getUpgradeData(@Nonnull RecipeUpgradeType type, @Nonnull ItemStack stack) {
    Item item = stack.getItem();
    switch(type) {
        case ENERGY:
            return new EnergyRecipeData(ItemDataUtils.getList(stack, NBTConstants.ENERGY_CONTAINERS));
        case FLUID:
            return new FluidRecipeData(ItemDataUtils.getList(stack, NBTConstants.FLUID_TANKS));
        case GAS:
            return new GasRecipeData(ItemDataUtils.getList(stack, NBTConstants.GAS_TANKS));
        case INFUSION:
            return new InfusionRecipeData(ItemDataUtils.getList(stack, NBTConstants.INFUSION_TANKS));
        case PIGMENT:
            return new PigmentRecipeData(ItemDataUtils.getList(stack, NBTConstants.PIGMENT_TANKS));
        case SLURRY:
            return new SlurryRecipeData(ItemDataUtils.getList(stack, NBTConstants.SLURRY_TANKS));
        case ITEM:
            return new ItemRecipeData(((ISustainedInventory) item).getInventory(stack));
        case SECURITY:
            ISecurityItem securityItem = (ISecurityItem) item;
            UUID ownerUUID = securityItem.getOwnerUUID(stack);
            return ownerUUID == null ? null : new SecurityRecipeData(ownerUUID, securityItem.getSecurity(stack));
        case UPGRADE:
            CompoundNBT componentUpgrade = ItemDataUtils.getCompound(stack, NBTConstants.COMPONENT_UPGRADE);
            return componentUpgrade.isEmpty() ? null : new UpgradesRecipeData(Upgrade.buildMap(componentUpgrade));
        case QIO_DRIVE:
            DriveMetadata data = DriveMetadata.load(stack);
            if (data.getCount() > 0 && ((IQIODriveItem) item).hasStoredItemMap(stack)) {
                // If we don't have any stored items don't actually grab any recipe data
                return new QIORecipeData(data, ItemDataUtils.getList(stack, NBTConstants.QIO_ITEM_MAP));
            }
            break;
    }
    return null;
}
Also used : DriveMetadata(mekanism.common.content.qio.IQIODriveItem.DriveMetadata) CompoundNBT(net.minecraft.nbt.CompoundNBT) GasRecipeData(mekanism.common.recipe.upgrade.chemical.GasRecipeData) SlurryRecipeData(mekanism.common.recipe.upgrade.chemical.SlurryRecipeData) IQIODriveItem(mekanism.common.content.qio.IQIODriveItem) Item(net.minecraft.item.Item) ISecurityItem(mekanism.common.lib.security.ISecurityItem) BlockItem(net.minecraft.item.BlockItem) ISecurityItem(mekanism.common.lib.security.ISecurityItem) PigmentRecipeData(mekanism.common.recipe.upgrade.chemical.PigmentRecipeData) UUID(java.util.UUID) InfusionRecipeData(mekanism.common.recipe.upgrade.chemical.InfusionRecipeData) Nullable(javax.annotation.Nullable)

Aggregations

UUID (java.util.UUID)1 Nullable (javax.annotation.Nullable)1 IQIODriveItem (mekanism.common.content.qio.IQIODriveItem)1 DriveMetadata (mekanism.common.content.qio.IQIODriveItem.DriveMetadata)1 ISecurityItem (mekanism.common.lib.security.ISecurityItem)1 GasRecipeData (mekanism.common.recipe.upgrade.chemical.GasRecipeData)1 InfusionRecipeData (mekanism.common.recipe.upgrade.chemical.InfusionRecipeData)1 PigmentRecipeData (mekanism.common.recipe.upgrade.chemical.PigmentRecipeData)1 SlurryRecipeData (mekanism.common.recipe.upgrade.chemical.SlurryRecipeData)1 BlockItem (net.minecraft.item.BlockItem)1 Item (net.minecraft.item.Item)1 CompoundNBT (net.minecraft.nbt.CompoundNBT)1