Search in sources :

Example 1 with FillGaugeBakery

use of crazypants.enderio.powertools.machine.capbank.render.FillGaugeBakery in project EnderIO by SleepyTrousers.

the class RenderMapperGauge method mapItemDynamicOverlayRender.

@Override
public ItemQuadCollector mapItemDynamicOverlayRender(@Nonnull Block block, @Nonnull ItemStack stack) {
    double v = EnderIO.proxy.getTickCount() % 120;
    if (v > 60) {
        v = 120 - v;
    }
    double ratio = v / 60d;
    FillGaugeBakery gauge = new FillGaugeBakery(BlockGauge.gaugeIcon.get(TextureAtlasSprite.class), ratio);
    if (gauge.canRender()) {
        ItemQuadCollector result = new ItemQuadCollector();
        List<BakedQuad> quads = new ArrayList<BakedQuad>();
        gauge.bake(quads);
        result.addQuads(null, quads);
        return result;
    }
    return null;
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) FillGaugeBakery(crazypants.enderio.powertools.machine.capbank.render.FillGaugeBakery) ArrayList(java.util.ArrayList) ItemQuadCollector(crazypants.enderio.base.render.util.ItemQuadCollector)

Example 2 with FillGaugeBakery

use of crazypants.enderio.powertools.machine.capbank.render.FillGaugeBakery 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();
            }
        }
    }
}
Also used : TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) EnumFacing(net.minecraft.util.EnumFacing) IPowerInterface(crazypants.enderio.base.power.IPowerInterface) FillGaugeBakery(crazypants.enderio.powertools.machine.capbank.render.FillGaugeBakery) World(net.minecraft.world.World)

Aggregations

FillGaugeBakery (crazypants.enderio.powertools.machine.capbank.render.FillGaugeBakery)2 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)2 IPowerInterface (crazypants.enderio.base.power.IPowerInterface)1 ItemQuadCollector (crazypants.enderio.base.render.util.ItemQuadCollector)1 ArrayList (java.util.ArrayList)1 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)1 EnumFacing (net.minecraft.util.EnumFacing)1 World (net.minecraft.world.World)1