<commit_before>package org.cyclops.commoncapabilities.modcompat.ic2.capability.tesla;

import ic2.api.item.IElectricItem;
import ic2.api.tile.IEnergyStorage;
import ic2.core.block.TileEntityBlock;
import net.darkhax.tesla.api.ITeslaHolder;
import net.darkhax.tesla.capability.TeslaCapabilities;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import org.cyclops.commoncapabilities.CommonCapabilities;
import org.cyclops.cyclopscore.modcompat.capabilities.CapabilityConstructorRegistry;
import org.cyclops.cyclopscore.modcompat.capabilities.ICapabilityConstructor;
import org.cyclops.cyclopscore.modcompat.capabilities.MultipleCapabilityProvider;
import org.cyclops.cyclopscore.modcompat.capabilities.SimpleCapabilityConstructor;

import javax.annotation.Nullable;

/**
 * Loader for IC2 Tesla capabilities.
 * @author rubensworks
 */
public class Ic2TeslaIntegration {

    public static void load() {
        CapabilityConstructorRegistry registry = CommonCapabilities._instance.getCapabilityConstructorRegistry();

        // Tiles
        registry.registerInheritableTile(IEnergyStorage.class,
                new SimpleCapabilityConstructor<ITeslaHolder, IEnergyStorage>() {
                    @Override
                    public Capability<ITeslaHolder> getCapability() {
                        return TeslaCapabilities.CAPABILITY_HOLDER;
                    }

                    @Nullable
                    @Override
                    public ICapabilityProvider createProvider(IEnergyStorage host) {
                        HolderProducerConsumerEnergyStorage capabilityImplementation = new HolderProducerConsumerEnergyStorage(host);
                        return MultipleCapabilityProvider.of(
                                TeslaCapabilities.CAPABILITY_HOLDER, capabilityImplementation,
                                TeslaCapabilities.CAPABILITY_PRODUCER, capabilityImplementation,
                                TeslaCapabilities.CAPABILITY_CONSUMER, capabilityImplementation
                        );
                    }
                });
        registry.registerInheritableTile(TileEntityBlock.class,
                new SimpleCapabilityConstructor<ITeslaHolder, TileEntityBlock>() {
                    @Override
                    public Capability<ITeslaHolder> getCapability() {
                        return TeslaCapabilities.CAPABILITY_HOLDER;
                    }

                    @Nullable
                    @Override
                    public ICapabilityProvider createProvider(TileEntityBlock host) {
                        HolderProducerConsumerBlock capabilityImplementation = new HolderProducerConsumerBlock(host);
                        return MultipleCapabilityProvider.of(
                                TeslaCapabilities.CAPABILITY_HOLDER, capabilityImplementation,
                                TeslaCapabilities.CAPABILITY_PRODUCER, capabilityImplementation,
                                TeslaCapabilities.CAPABILITY_CONSUMER, capabilityImplementation
                        );
                    }
                });

        // Items
        registry.registerInheritableItem(IElectricItem.class,
                new ICapabilityConstructor<ITeslaHolder, IElectricItem, ItemStack>() {
                    @Override
                    public Capability<ITeslaHolder> getCapability() {
                        return TeslaCapabilities.CAPABILITY_HOLDER;
                    }

                    @Nullable
                    @Override
                    public ICapabilityProvider createProvider(IElectricItem hostType, final ItemStack host) {
                        HolderProducerConsumerElectricItem capabilityImplementation = new HolderProducerConsumerElectricItem(hostType, host);
                        return MultipleCapabilityProvider.of(<commit_msg>Fix duplicate Tesla capability on IC2 storage tiles<commit_after>package org.cyclops.commoncapabilities.modcompat.ic2.capability.tesla;

import ic2.api.item.IElectricItem;
import ic2.api.tile.IEnergyStorage;
import ic2.core.block.TileEntityBlock;
import net.darkhax.tesla.api.ITeslaHolder;
import net.darkhax.tesla.capability.TeslaCapabilities;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import org.cyclops.commoncapabilities.CommonCapabilities;
import org.cyclops.cyclopscore.modcompat.capabilities.CapabilityConstructorRegistry;
import org.cyclops.cyclopscore.modcompat.capabilities.ICapabilityConstructor;
import org.cyclops.cyclopscore.modcompat.capabilities.MultipleCapabilityProvider;
import org.cyclops.cyclopscore.modcompat.capabilities.SimpleCapabilityConstructor;

import javax.annotation.Nullable;

/**
 * Loader for IC2 Tesla capabilities.
 * @author rubensworks
 */
public class Ic2TeslaIntegration {

    public static void load() {
        CapabilityConstructorRegistry registry = CommonCapabilities._instance.getCapabilityConstructorRegistry();

        // Tiles
        registry.registerInheritableTile(IEnergyStorage.class,
                new SimpleCapabilityConstructor<ITeslaHolder, IEnergyStorage>() {
                    @Override
                    public Capability<ITeslaHolder> getCapability() {
                        return TeslaCapabilities.CAPABILITY_HOLDER;
                    }

                    @Nullable
                    @Override
                    public ICapabilityProvider createProvider(IEnergyStorage host) {
                        HolderProducerConsumerEnergyStorage capabilityImplementation = new HolderProducerConsumerEnergyStorage(host);
                        return MultipleCapabilityProvider.of(
                                TeslaCapabilities.CAPABILITY_HOLDER, capabilityImplementation,
                                TeslaCapabilities.CAPABILITY_PRODUCER, capabilityImplementation,
                                TeslaCapabilities.CAPABILITY_CONSUMER, capabilityImplementation
                        );
                    }
                });
        registry.registerInheritableTile(TileEntityBlock.class,
                new SimpleCapabilityConstructor<ITeslaHolder, TileEntityBlock>() {
                    @Override
                    public Capability<ITeslaHolder> getCapability() {
                        return TeslaCapabilities.CAPABILITY_HOLDER;
                    }

                    @Nullable
                    @Override
                    public ICapabilityProvider createProvider(TileEntityBlock host) {
                        if (!(host instanceof IEnergyStorage)) {
                            HolderProducerConsumerBlock capabilityImplementation = new HolderProducerConsumerBlock(host);
                            return MultipleCapabilityProvider.of(
                                    TeslaCapabilities.CAPABILITY_HOLDER, capabilityImplementation,
                                    TeslaCapabilities.CAPABILITY_PRODUCER, capabilityImplementation,
                                    TeslaCapabilities.CAPABILITY_CONSUMER, capabilityImplementation
                            );
                        }
                        return null;
                    }
                });

        // Items
        registry.registerInheritableItem(IElectricItem.class,
                new ICapabilityConstructor<ITeslaHolder, IElectricItem, ItemStack>() {
                    @Override
                    public Capability<ITeslaHolder> getCapability() {
                        return TeslaCapabilities.CAPABILITY_HOLDER;
                    }

                    @Nullable
                    @Override
                    public ICapabilityProvider createProvider(IElectricItem hostType, final ItemStack host) {
                        HolderProducerConsumerElectricItem capabilityImplementation = new HolderProducerConsumerElectricItem(hostType, host);
                        return MultipleCapabilityProvider.of(
{'fraction_non_alphanumeric': 0.0556792873051225, 'fraction_numerical': 0.0016085127443702053, 'mean_word_length': 2.1016884113584036, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7397118', 'n_tokens_mistral': 1900, 'n_tokens_neox': 1759, 'n_words': 276}