<commit_before>package mcjty.rftools.varia;

import cofh.api.energy.IEnergyHandler;
import cofh.api.energy.IEnergyProvider;
import cofh.api.energy.IEnergyReceiver;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;

public class EnergyTools {

    public static class EnergyLevel {
        private final int energy;
        private final int maxEnergy;

        public EnergyLevel(int energy, int maxEnergy) {
            this.energy = energy;
            this.maxEnergy = maxEnergy;
        }

        public int getEnergy() {
            return energy;
        }

        public int getMaxEnergy() {
            return maxEnergy;
        }
    }

    public static class EnergyLevelMulti {
        private final long energy;
        private final long maxEnergy;

        public EnergyLevelMulti(long energy, long maxEnergy) {
            this.energy = energy;
            this.maxEnergy = maxEnergy;
        }

        public long getEnergy() {
            return energy;
        }

        public long getMaxEnergy() {
            return maxEnergy;
        }
    }

    public static boolean isEnergyTE(TileEntity te) {
        return te instanceof IEnergyHandler || te instanceof IEnergyReceiver || te instanceof IEnergyProvider;
    }

    // Get energy level with possible support for multiblocks (like EnderIO capacitor bank).
    public static EnergyLevelMulti getEnergyLevelMulti(TileEntity tileEntity) {
        long maxEnergyStored;
        long energyStored;
        if (tileEntity instanceof IEnergyHandler) {
            IEnergyHandler handler = (IEnergyHandler) tileEntity;
            maxEnergyStored = handler.getMaxEnergyStored(EnumFacing.DOWN);
            energyStored = handler.getEnergyStored(EnumFacing.DOWN);
        } else if (tileEntity instanceof IEnergyReceiver) {
            IEnergyReceiver handler = (IEnergyReceiver) tileEntity;
            maxEnergyStored = handler.getMaxEnergyStored(EnumFacing.DOWN);
            energyStored = handler.getEnergyStored(EnumFacing.DOWN);
        } else if (tileEntity instanceof IEnergyProvider) {
            IEnergyProvider handler = (IEnergyProvider) tileEntity;
            maxEnergyStored = handler.getMaxEnergyStored(EnumFacing.DOWN);
            energyStored = handler.getEnergyStored(EnumFacing.DOWN);
        } else {
            maxEnergyStored = 0;
            energyStored = 0;
        }
        return new EnergyLevelMulti(energyStored, maxEnergyStored);
    }

    public static EnergyLevel getEnergyLevel(TileEntity tileEntity) {
        int maxEnergyStored;
        int energyStored;
        if (tileEntity instanceof IEnergyHandler) {
            IEnergyHandler handler = (IEnergyHandler) tileEntity;
            maxEnergyStored = handler.getMaxEnergyStored(EnumFacing.DOWN);
            energyStored = handler.getEnergyStored(EnumFacing.DOWN);
        } else if (tileEntity instanceof IEnergyReceiver) {
            IEnergyReceiver handler = (IEnergyReceiver) tileEntity;
            maxEnergyStored = handler.getMaxEnergyStored(EnumFacing.DOWN);
            energyStored = handler.getEnergyStored(EnumFacing.DOWN);
        } else if (tileEntity instanceof IEnergyProvider) {
            IEnergyProvider handler = (IEnergyProvider) tileEntity;
            maxEnergyStored = handler.getMaxEnergyStored(EnumFacing.DOWN);
            energyStored = handler.getEnergyStored(EnumFacing.DOWN);
        } else {
            maxEnergyStored = 0;
            energyStored = 0;
        }
        return new EnergyLevel(energyStored, maxEnergyStored);
    }

    public static int extractEnergy(TileEntity tileEntity, EnumFacing from, int maxExtract) {
        if (tileEntity instanceof IEnergyProvider) {<commit_msg>Some cleanups<commit_after>package mcjty.rftools.varia;

import cofh.api.energy.IEnergyHandler;
import cofh.api.energy.IEnergyProvider;
import cofh.api.energy.IEnergyReceiver;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;

public class EnergyTools {

    public static class EnergyLevel {
        private final int energy;
        private final int maxEnergy;

        public EnergyLevel(int energy, int maxEnergy) {
            this.energy = energy;
            this.maxEnergy = maxEnergy;
        }

        public int getEnergy() {
            return energy;
        }

        public int getMaxEnergy() {
            return maxEnergy;
        }
    }

    public static class EnergyLevelMulti {
        private final long energy;
        private final long maxEnergy;

        public EnergyLevelMulti(long energy, long maxEnergy) {
            this.energy = energy;
            this.maxEnergy = maxEnergy;
        }

        public long getEnergy() {
            return energy;
        }

        public long getMaxEnergy() {
            return maxEnergy;
        }
    }

    public static boolean isEnergyTE(TileEntity te) {
        return te instanceof IEnergyHandler;
    }

    // Get energy level with possible support for multiblocks (like EnderIO capacitor bank).
    public static EnergyLevelMulti getEnergyLevelMulti(TileEntity tileEntity) {
        long maxEnergyStored;
        long energyStored;
        if (tileEntity instanceof IEnergyHandler) {
            IEnergyHandler handler = (IEnergyHandler) tileEntity;
            maxEnergyStored = handler.getMaxEnergyStored(EnumFacing.DOWN);
            energyStored = handler.getEnergyStored(EnumFacing.DOWN);
        } else {
            maxEnergyStored = 0;
            energyStored = 0;
        }
        return new EnergyLevelMulti(energyStored, maxEnergyStored);
    }

    public static EnergyLevel getEnergyLevel(TileEntity tileEntity) {
        int maxEnergyStored;
        int energyStored;
        if (tileEntity instanceof IEnergyHandler) {
            IEnergyHandler handler = (IEnergyHandler) tileEntity;
            maxEnergyStored = handler.getMaxEnergyStored(EnumFacing.DOWN);
            energyStored = handler.getEnergyStored(EnumFacing.DOWN);
        } else {
            maxEnergyStored = 0;
            energyStored = 0;
        }
        return new EnergyLevel(energyStored, maxEnergyStored);
    }

    public static int extractEnergy(TileEntity tileEntity, EnumFacing from, int maxExtract) {
        if (tileEntity instanceof IEnergyProvider) {
{'fraction_non_alphanumeric': 0.06643356643356643, 'fraction_numerical': 0.0012714558169103624, 'mean_word_length': 2.476795580110497, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2761803', 'n_tokens_mistral': 1709, 'n_tokens_neox': 1600, 'n_words': 401}