Search in sources :

Example 16 with ITessellator

use of com.infinityraider.infinitylib.render.tessellation.ITessellator in project AgriCraft by AgriCraft.

the class AgriPlantQuadGenerator method bakeQuadsForPlusPattern.

@Nonnull
public List<BakedQuad> bakeQuadsForPlusPattern(IAgriGrowable plant, IAgriGrowthStage stage, @Nullable Direction face, IntFunction<TextureAtlasSprite> spriteFunc) {
    if (face != null) {
        return ImmutableList.of();
    }
    ITessellator tessellator = this.getTessellator();
    tessellator.startDrawingQuads();
    tessellator.setFace((Direction) null);
    tessellator.pushMatrix();
    double height = plant.getPlantHeight(stage);
    int layers = (int) Math.ceil(height / 12.0);
    int layer = 0;
    while ((12 * layer) < height) {
        TextureAtlasSprite sprite = spriteFunc.apply(layers - layer - 1);
        tessellator.drawScaledFaceDouble(-2, 0, 10, 12, Direction.NORTH, sprite, 4.001F, 0, 0, 16, 16);
        tessellator.drawScaledFaceDouble(6, 0, 18, 12, Direction.NORTH, sprite, 3.999F, 0, 0, 16, 16);
        tessellator.drawScaledFaceDouble(-2, 0, 10, 12, Direction.EAST, sprite, 4.001F, 0, 0, 16, 16);
        tessellator.drawScaledFaceDouble(6, 0, 18, 12, Direction.EAST, sprite, 3.999F, 0, 0, 16, 16);
        tessellator.drawScaledFaceDouble(-2, 0, 10, 12, Direction.NORTH, sprite, 12.001F, 0, 0, 16, 16);
        tessellator.drawScaledFaceDouble(6, 0, 18, 12, Direction.NORTH, sprite, 11.999F, 0, 0, 16, 16);
        tessellator.drawScaledFaceDouble(-2, 0, 10, 12, Direction.EAST, sprite, 12.001F, 0, 0, 16, 16);
        tessellator.drawScaledFaceDouble(6, 0, 18, 12, Direction.EAST, sprite, 11.999F, 0, 0, 16, 16);
        tessellator.translate(0, 12.0F / 16.0F, 0);
        layer++;
    }
    tessellator.popMatrix();
    List<BakedQuad> quads = tessellator.getQuads();
    tessellator.draw();
    return quads;
}
Also used : ITessellator(com.infinityraider.infinitylib.render.tessellation.ITessellator) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) Nonnull(javax.annotation.Nonnull)

Example 17 with ITessellator

use of com.infinityraider.infinitylib.render.tessellation.ITessellator in project AgriCraft by AgriCraft.

the class TileEntityIrrigationChannelRenderer method renderWater.

@Override
protected void renderWater(TileEntityIrrigationChannel tile, float partialTicks, MatrixStack transforms, IRenderTypeBuffer.Impl buffer, int light, int overlay) {
    float level = tile.getRenderLevel(partialTicks) - tile.getPos().getY();
    float min = tile.getMinLevel() - tile.getPos().getY();
    level = level == 0 ? min : level;
    ITessellator tessellator = this.getTessellator(buffer);
    this.applyWaterColor(tile, tessellator.startDrawingQuads()).setBrightness(light).setOverlay(overlay).pushMatrix();
    tessellator.applyTransformation(transforms.getLast().getMatrix());
    if (tile.getContent() > 0 && tile.isOpen()) {
        tessellator.drawScaledFace(6, 6, 10, 10, Direction.UP, this.getWaterTexture(), Constants.WHOLE * level);
    }
    this.drawConnectionNorth(tessellator, tile, partialTicks);
    this.drawConnectionEast(tessellator, tile, partialTicks);
    this.drawConnectionSouth(tessellator, tile, partialTicks);
    this.drawConnectionWest(tessellator, tile, partialTicks);
    if (tile.hasValve() && tile.hasHandWheel()) {
        tessellator.popMatrix().pushMatrix();
        this.renderValveHandWheel(tessellator, tile, transforms, partialTicks);
    }
    tessellator.popMatrix().draw();
}
Also used : ITessellator(com.infinityraider.infinitylib.render.tessellation.ITessellator)

Aggregations

ITessellator (com.infinityraider.infinitylib.render.tessellation.ITessellator)17 Nonnull (javax.annotation.Nonnull)6 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)6 IRenderTypeBuffer (net.minecraft.client.renderer.IRenderTypeBuffer)2 ImmutableList (com.google.common.collect.ImmutableList)1 IAgriPlant (com.infinityraider.agricraft.api.v1.plant.IAgriPlant)1 BakedQuad (net.minecraft.client.renderer.model.BakedQuad)1