package com.harry9137.ct.tileentity;
import com.harry9137.ct.energy.IEnergyContainer;
import com.harry9137.ct.utillity.ListHelper;
import com.harry9137.ct.utillity.LogHelper;
import com.harry9137.ct.utillity.TileHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import java.util.ArrayList;
public class TileEntityBattery extends TileEntity implements IEnergyContainer, ITickUpdater{
public int PowerStorageMax = 1000;
public int PowerStored;
public boolean PowerGen = true;
public boolean PowerSrc = true;
private String PowerDisplayMessage;
private int UpdateTick = 0;
public TileEntityBattery(){
}
@Override
public void updateEntity(){
/* ArrayList<IEnergyContainer> availableBlocks = new ArrayList<IEnergyContainer>();
if(UpdateTick == 5) {
availableBlocks.clear();
for (TileEntity temp : TileHelper.getBlockSides(this)) {
if (temp instanceof TileEntityWire) {
ArrayList<IEnergyContainer> temp2 = ((TileEntityWire) temp).getPossibleConnections(this);
availableBlocks = ListHelper.combine(temp2, availableBlocks);
}
if (temp instanceof IEnergyContainer && !(temp instanceof TileEntityWire)) {
availableBlocks.add((IEnergyContainer) temp);
}
}
UpdateTick = 0;
try {
this.worldObj.getPlayerEntityByName("Harry9137").addChatComponentMessage(new ChatComponentText(Integer.toString(PowerStored)));
}
catch(NullPointerException e){
}
}
for(IEnergyContainer temp3 : availableBlocks){
if(temp3.getCanReceivePower() && this.PowerStored > 0){
temp3.setPowerLevel(temp3.getEnergyLevel() + 1);
this.PowerStored--;
}
}
UpdateTick++;*/
}
@Override
public void writeToNBT(NBTTagCompound tagCompound) {
super.writeToNBT(tagCompound);
tagCompound.setInteger("PowerStored", this.PowerStored);
}
@Override
public void readFromNBT(NBTTagCompound tagCompound){
super.readFromNBT(tagCompound);
this.PowerStored = tagCompound.getInteger("PowerStored");
}
@Override
public int getEnergyLevel() {
return PowerStored;
}
@Override
public boolean getCanSendPower() {
return true;
}
@Override
public boolean getCanReceivePower() {
return true;
}
@Override
public int getEnergyMax() {
return 1000;
}
@Override
public void onEnergyUpdate() {
}
@Override
public void setPowerLevel(int powerLevel) {
this.PowerStored = powerLevel;
}
}