controller emits a comparator signal now
This commit is contained in:
@@ -45,6 +45,20 @@ public class BlockController extends BlockBase implements ITileEntityProvider
|
||||
super.onBlockPreDestroy(world, x, y, z, meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorInputOverride()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride(World world, int x, int y, int z, int side)
|
||||
{
|
||||
TileController tile = (TileController) world.getTileEntity(x, y, z);
|
||||
|
||||
return tile.getEnergyScaled(15);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register)
|
||||
{
|
||||
@@ -63,7 +77,7 @@ public class BlockController extends BlockBase implements ITileEntityProvider
|
||||
|
||||
if (side == tile.getDirection().ordinal())
|
||||
{
|
||||
return icons[(int) ((float) tile.getEnergyStored(null) / (float) tile.getMaxEnergyStored(null) * 8f)];
|
||||
return icons[tile.getEnergyScaled(8)];
|
||||
}
|
||||
|
||||
return sideIcon;
|
||||
|
@@ -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)
|
||||
{
|
||||
|
Reference in New Issue
Block a user