use of crazypants.enderio.base.power.IPowerInterface in project EnderIO by SleepyTrousers.
the class TESRGauge method renderTileEntity.
@Override
protected void renderTileEntity(@Nonnull TileGauge te, @Nonnull IBlockState blockState, float partialTicks, int destroyStage) {
RenderHelper.enableStandardItemLighting();
World world = te.getWorld();
Map<EnumFacing, IPowerInterface> sides = BlockGauge.getDisplays(world, te.getPos());
if (!sides.isEmpty()) {
for (Entry<EnumFacing, IPowerInterface> side : sides.entrySet()) {
IPowerInterface eh = side.getValue();
EnumFacing face = side.getKey().getOpposite();
int energyStored = eh.getEnergyStored();
int maxEnergyStored = eh.getMaxEnergyStored();
float ratio = maxEnergyStored > 0 ? (float) energyStored / (float) maxEnergyStored : 0f;
FillGaugeBakery bakery = new FillGaugeBakery(world, te.getPos().offset(NullHelper.first(side.getKey(), EnumFacing.DOWN)), face, BlockGauge.gaugeIcon.get(TextureAtlasSprite.class), ratio);
if (bakery.canRender()) {
GL11.glPushMatrix();
GL11.glTranslated(-face.getFrontOffsetX(), -face.getFrontOffsetY(), -face.getFrontOffsetZ());
bakery.render();
GL11.glPopMatrix();
}
}
} else {
double v = EnderIO.proxy.getTickCount() % 100 + partialTicks;
if (v > 50) {
v = 100 - v;
}
double ratio = v / 50d;
for (EnumFacing face : EnumFacing.Plane.HORIZONTAL) {
FillGaugeBakery bakery = new FillGaugeBakery(world, te.getPos().offset(face.getOpposite()), face, BlockGauge.gaugeIcon.get(TextureAtlasSprite.class), ratio);
if (bakery.canRender()) {
// sic!
GL11.glPushMatrix();
GL11.glTranslated(-face.getFrontOffsetX(), -face.getFrontOffsetY(), -face.getFrontOffsetZ());
bakery.render();
GL11.glPopMatrix();
}
}
}
}
use of crazypants.enderio.base.power.IPowerInterface in project EnderIO by SleepyTrousers.
the class TileCapBank method toggleIoModeForFace.
// ---------- IO
@Override
@Nonnull
public IoMode toggleIoModeForFace(@Nullable EnumFacing faceHit) {
if (faceHit == null) {
return IoMode.NONE;
}
IPowerInterface rec = getReceptorForFace(faceHit);
IoMode curMode = getIoMode(faceHit);
if (curMode == IoMode.PULL) {
setIoMode(faceHit, IoMode.PUSH, true);
return IoMode.PUSH;
}
if (curMode == IoMode.PUSH) {
setIoMode(faceHit, IoMode.DISABLED, true);
return IoMode.DISABLED;
}
if (curMode == IoMode.DISABLED) {
if (rec == null || rec.getProvider() instanceof IConduitBundle) {
setIoMode(faceHit, IoMode.NONE, true);
return IoMode.NONE;
}
}
setIoMode(faceHit, IoMode.PULL, true);
return IoMode.PULL;
}
use of crazypants.enderio.base.power.IPowerInterface in project EnderIO by SleepyTrousers.
the class NetworkPowerManager method getMaxPowerInReceptors.
public long getMaxPowerInReceptors() {
long result = 0;
Set<Object> done = new HashSet<Object>();
for (ReceptorEntry re : receptors) {
if (!re.emmiter.getConnectionsDirty()) {
IPowerInterface powerReceptor = re.powerInterface;
if (!done.contains(powerReceptor.getProvider())) {
done.add(powerReceptor.getProvider());
result += powerReceptor.getMaxEnergyStored();
}
}
}
return result;
}
Aggregations