use of com.infinityraider.agricraft.handler.SeedAnalyzerViewPointHandler 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();
}
Aggregations