controller emits a comparator signal now

This commit is contained in:
Raoul Van den Berge
2015-12-23 16:27:22 +01:00
parent c4bcba1ed6
commit 9f9ab2dca3
2 changed files with 29 additions and 5 deletions

View File

@@ -10,6 +10,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Vec3;
import net.minecraftforge.common.util.ForgeDirection;
import storagecraft.StorageCraftBlocks;
import storagecraft.storage.IStorage;
import storagecraft.storage.IStorageProvider;
import storagecraft.storage.StorageItem;
@@ -43,6 +44,8 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
if (!worldObj.isRemote)
{
int lastEnergy = energy.getEnergyStored();
if (ticks % 40 == 0)
{
if (!isActive())
@@ -110,10 +113,12 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
}
energy.extractEnergy(energyUsage, false);
}
else
{
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
if (lastEnergy != energy.getEnergyStored())
{
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, StorageCraftBlocks.CONTROLLER);
}
}
}
@@ -299,6 +304,11 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
return energy.getEnergyStored();
}
public int getEnergyScaled(int i)
{
return (int) ((float) energy.getEnergyStored() / (float) energy.getMaxEnergyStored() * (float) i);
}
@Override
public int getMaxEnergyStored(ForgeDirection from)
{