<commit_before>package reborncore.common.powerSystem.tesla;

import net.darkhax.tesla.api.ITeslaConsumer;
import net.darkhax.tesla.api.ITeslaHolder;
import net.darkhax.tesla.api.ITeslaProducer;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import reborncore.common.RebornCoreConfig;
import reborncore.common.powerSystem.TilePowerAcceptor;

/**
 * Created by modmuss50 on 06/05/2016.
 */
public class AdvancedTeslaContainer implements ITeslaConsumer, ITeslaHolder, ITeslaProducer {

	public TilePowerAcceptor tile;

	public AdvancedTeslaContainer(TilePowerAcceptor tile) {
		this.tile = tile;
	}

	public AdvancedTeslaContainer(NBTBase nbt, TilePowerAcceptor tile) {
		this.tile = tile;
		this.readNBT(nbt);
	}

	public long getStoredPower() {
		return (long) tile.getEnergy() * RebornCoreConfig.euPerFU;
	}

	//Receive
	public long givePower(long tesla, boolean simulated) {
		return (long) tile.addEnergy(tesla * RebornCoreConfig.euPerFU);
	}

	//Take power out
	public long takePower(long tesla, boolean simulated) {
		return (int) tile.useEnergy(tesla * RebornCoreConfig.euPerFU);
	}

	public long getCapacity() {
		return (long) tile.getMaxPower() * RebornCoreConfig.euPerFU;
	}

	public long getInputRate() {
		return (long) tile.getMaxInput() * RebornCoreConfig.euPerFU;
	}

	public long getOutputRate() {
		return (long) tile.getMaxOutput() * RebornCoreConfig.euPerFU;
	}

	public NBTBase writeNBT() {
		NBTTagCompound dataTag = new NBTTagCompound();
		return dataTag;
	}

	public void readNBT(NBTBase nbt) {
	}

	public boolean isInputSide() {
		return true;<commit_msg>Make givePower/takePower check for canAddEnergy/canUseEnergy<commit_after>package reborncore.common.powerSystem.tesla;

import net.darkhax.tesla.api.ITeslaConsumer;
import net.darkhax.tesla.api.ITeslaHolder;
import net.darkhax.tesla.api.ITeslaProducer;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import reborncore.common.RebornCoreConfig;
import reborncore.common.powerSystem.TilePowerAcceptor;

/**
 * Created by modmuss50 on 06/05/2016.
 */
public class AdvancedTeslaContainer implements ITeslaConsumer, ITeslaHolder, ITeslaProducer {

	public TilePowerAcceptor tile;

	public AdvancedTeslaContainer(TilePowerAcceptor tile) {
		this.tile = tile;
	}

	public AdvancedTeslaContainer(NBTBase nbt, TilePowerAcceptor tile) {
		this.tile = tile;
		this.readNBT(nbt);
	}

	public long getStoredPower() {
		return (long) tile.getEnergy() * RebornCoreConfig.euPerFU;
	}

	//Receive
	public long givePower(long tesla, boolean simulated) {
		double euToAdd = tesla * RebornCoreConfig.euPerFU;

		if (tile.canAddEnergy(euToAdd)) {
			double euAdded = tile.addEnergy(euToAdd);
			return (long) (euAdded / RebornCoreConfig.euPerFU);
		} else {
			return 0;
		}
	}

	//Take power out
	public long takePower(long tesla, boolean simulated) {
		double euToTake = tesla * RebornCoreConfig.euPerFU;

		if (tile.canUseEnergy(euToTake)) {
			double euTaken = tile.useEnergy(euToTake);
			return (long) (euTaken / RebornCoreConfig.euPerFU);
		} else {
			return 0;
		}
	}

	public long getCapacity() {
		return (long) tile.getMaxPower() * RebornCoreConfig.euPerFU;
	}

	public long getInputRate() {
		return (long) tile.getMaxInput() * RebornCoreConfig.euPerFU;
	}

	public long getOutputRate() {
		return (long) tile.getMaxOutput() * RebornCoreConfig.euPerFU;
	}

	public NBTBase writeNBT() {
		NBTTagCompound dataTag = new NBTTagCompound();
		return dataTag;
	}

	public void readNBT(NBTBase nbt) {
	}

	public boolean isInputSide() {
		return true;
{'fraction_non_alphanumeric': 0.10254973381899692, 'fraction_numerical': 0.006164191650322219, 'mean_word_length': 4.900826446280992, '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': '3439350', 'n_tokens_mistral': 1367, 'n_tokens_neox': 1255, 'n_words': 255}