Skip to content

Commit

Permalink
Fix a crash caused by using the global tessellator instead of our own.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexIIL committed Feb 27, 2019
1 parent e688492 commit a1300dd
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,19 @@
import buildcraft.lib.expression.node.value.NodeVariableDouble;

public class BakedImageRender extends BakedRenderPositioned {

/** We only ever render 4 x (3 pos, 2 uv) ints each time then reset for the next face.
* <p>
* So this 64 is overkill. */
private static final int TESS_INT_COUNT = 0x40;

private final Tessellator tess = new Tessellator(TESS_INT_COUNT);

protected final ResourceLocation res;
private final BakedArea pos, tex;

public BakedImageRender(NodeVariableDouble varWidth, NodeVariableDouble varHeight, String res, BakedArea pos, BakedArea tex) {
public BakedImageRender(NodeVariableDouble varWidth, NodeVariableDouble varHeight, String res, BakedArea pos,
BakedArea tex) {
super(varWidth, varHeight);
this.res = new ResourceLocation(res);
this.pos = pos;
Expand All @@ -33,14 +42,13 @@ public void evaluateVariables(MinecraftDisplayerRenderer renderer) {
@Override
public void render(MinecraftDisplayerRenderer renderer) {
bindTexture(renderer);
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder vb = tessellator.getBuffer();
BufferBuilder vb = tess.getBuffer();
vb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
vb.pos(pos._x, pos._y + pos._h, 0).tex(tex._x, tex._y + tex._h).endVertex();
vb.pos(pos._x + pos._w, pos._y + pos._h, 0).tex(tex._x + tex._w, tex._y + tex._h).endVertex();
vb.pos(pos._x + pos._w, pos._y, 0).tex(tex._x + tex._w, tex._y).endVertex();
vb.pos(pos._x, pos._y, 0).tex(tex._x, tex._y).endVertex();
tessellator.draw();
tess.draw();
}

public void bindTexture(MinecraftDisplayerRenderer renderer) {
Expand Down

0 comments on commit a1300dd

Please sign in to comment.