Search in sources :

Example 1 with AgriGenomeRenderer

use of com.infinityraider.agricraft.render.plant.AgriGenomeRenderer in project AgriCraft by AgriCraft.

the class TileEntitySeedAnalyzerSeedRenderer method renderGenome.

protected void renderGenome(TileEntitySeedAnalyzer tile, float partialTick, MatrixStack transforms, IRenderTypeBuffer buffer) {
    // fetch genes
    List<IAgriGenePair<?>> genes = tile.getGenesToRender();
    if (genes == null) {
        // should never be possible
        return;
    }
    // push a new matrix to the stack
    transforms.push();
    // fetch helpers
    SeedAnalyzerViewPointHandler viewHandler = SeedAnalyzerViewPointHandler.getInstance();
    AgriGenomeRenderer renderer = AgriGenomeRenderer.getInstance();
    // fetch scroll position
    int index = viewHandler.getScrollIndex();
    float partial = viewHandler.getPartialScrollProgress(partialTick);
    // fetch orientation
    BlockState state = tile.getBlockState();
    Direction dir = BlockSeedAnalyzer.ORIENTATION.fetch(state);
    // helix dimensions
    float h = Constants.HALF;
    float r = h / 10;
    // transform to the desired position
    float dx = Constants.HALF + Constants.UNIT * dir.getXOffset();
    float dy = 5 * Constants.UNIT;
    float dz = Constants.HALF + Constants.UNIT * dir.getZOffset();
    transforms.translate(dx, dy, dz);
    transforms.rotate(new Quaternion(Vector3f.YP, tile.getHorizontalAngle(), true));
    // render the helix
    renderer.renderDoubleHelix(genes, transforms, buffer, index, partial, r, h, 1.0F, false);
    // render the text
    if (index >= 0 && index < genes.size()) {
        transforms.push();
        transforms.translate(0, 0, -3 * Constants.UNIT);
        transforms.rotate(TEXT_ROTATION);
        float scale = 2.0F / Math.max(this.getScaledWindowWidth(), this.getScaledWindowHeight());
        transforms.scale(scale, scale, 1);
        renderer.renderTextOverlay(transforms, genes.get(index));
        transforms.pop();
    }
    // pop the matrix off the stack
    transforms.pop();
}
Also used : IAgriGenePair(com.infinityraider.agricraft.api.v1.genetics.IAgriGenePair) BlockState(net.minecraft.block.BlockState) Quaternion(net.minecraft.util.math.vector.Quaternion) SeedAnalyzerViewPointHandler(com.infinityraider.agricraft.handler.SeedAnalyzerViewPointHandler) Direction(net.minecraft.util.Direction) AgriGenomeRenderer(com.infinityraider.agricraft.render.plant.AgriGenomeRenderer)

Aggregations

IAgriGenePair (com.infinityraider.agricraft.api.v1.genetics.IAgriGenePair)1 SeedAnalyzerViewPointHandler (com.infinityraider.agricraft.handler.SeedAnalyzerViewPointHandler)1 AgriGenomeRenderer (com.infinityraider.agricraft.render.plant.AgriGenomeRenderer)1 BlockState (net.minecraft.block.BlockState)1 Direction (net.minecraft.util.Direction)1 Quaternion (net.minecraft.util.math.vector.Quaternion)1