Search in sources :

Example 1 with IElectricStats

use of gregtech.api.items.metaitem.stats.IElectricStats in project GregTech by GregTechCE.

the class MetaItem method initCapabilities.

// ////////////////////////////////////////////////////////////////
// FluidContainer Stuff                     //
// ////////////////////////////////////////////////////////////////
@Nullable
@Override
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) {
    T metaValueItem = getItem(stack);
    if (metaValueItem == null) {
        return null;
    }
    IFluidStats fluidStats = metaValueItem.getFluidStats();
    IElectricStats electricStats = metaValueItem.getElectricStats();
    if (electricStats != null && fluidStats != null) {
        ThermalFluidHandlerItemStack handlerItemStack = new ThermalFluidHandlerItemStack(stack, fluidStats.getCapacity(stack), fluidStats.getMinFluidTemperature(stack), fluidStats.getMaxFluidTemperature(stack));
        ElectricItem electricItem = new ElectricItem(electricStats.getMaxCharge(), electricStats.getTier(), electricStats.isChargeable(), electricStats.isDischargeable());
        return new CombinedCapabilityProvider(handlerItemStack, electricItem);
    }
    if (fluidStats != null) {
        return new ThermalFluidHandlerItemStack(stack, fluidStats.getCapacity(stack), fluidStats.getMinFluidTemperature(stack), fluidStats.getMaxFluidTemperature(stack));
    }
    if (electricStats != null) {
        return new ElectricItem(electricStats.getMaxCharge(), electricStats.getTier(), electricStats.isChargeable(), electricStats.isDischargeable());
    }
    return null;
}
Also used : IFluidStats(gregtech.api.items.metaitem.stats.IFluidStats) ThermalFluidHandlerItemStack(gregtech.api.capability.impl.ThermalFluidHandlerItemStack) IElectricStats(gregtech.api.items.metaitem.stats.IElectricStats) CombinedCapabilityProvider(gregtech.api.capability.impl.CombinedCapabilityProvider) ElectricItem(gregtech.api.capability.impl.ElectricItem) Nullable(javax.annotation.Nullable)

Example 2 with IElectricStats

use of gregtech.api.items.metaitem.stats.IElectricStats in project GregTech by GregTechCE.

the class MetaItem method getElectricStats.

// ////////////////////////////////////////////////////////////////
// ISpecialElectricItem Implementation          //
// ////////////////////////////////////////////////////////////////
protected IElectricStats getElectricStats(ItemStack itemStack) {
    T metaValueItem = getItem(itemStack);
    if (metaValueItem == null) {
        return ElectricStats.EMPTY;
    }
    IElectricStats electricStats = metaValueItem.getElectricStats();
    if (electricStats == null) {
        return ElectricStats.EMPTY;
    }
    return electricStats;
}
Also used : IElectricStats(gregtech.api.items.metaitem.stats.IElectricStats)

Aggregations

IElectricStats (gregtech.api.items.metaitem.stats.IElectricStats)2 CombinedCapabilityProvider (gregtech.api.capability.impl.CombinedCapabilityProvider)1 ElectricItem (gregtech.api.capability.impl.ElectricItem)1 ThermalFluidHandlerItemStack (gregtech.api.capability.impl.ThermalFluidHandlerItemStack)1 IFluidStats (gregtech.api.items.metaitem.stats.IFluidStats)1 Nullable (javax.annotation.Nullable)1