Cache Tessellator#instance in local var (#321)

This commit is contained in:
Alexdoru authored and GitHub committed 2025-07-18 11:51:16 -07:00
1 parent ae7af4e712
commit 1e66772abc
5 files changed
+43 -37

No files matched your search

@@ -344,7 +344,8 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
/* Draws the top part. */ /* Draws the top part. */
drawTexturedModalRect(offsetX, offsetY, 0, 0, xSize, HEADER_HEIGHT); drawTexturedModalRect(offsetX, offsetY, 0, 0, xSize, HEADER_HEIGHT);
/* Draws the middle part. */ /* Draws the middle part. */
Tessellator.instance.startDrawingQuads(); final Tessellator tess = Tessellator.instance;
tess.startDrawingQuads();
addTexturedRectToTesselator( addTexturedRectToTesselator(
offsetX, offsetX,
offsetY + HEADER_HEIGHT, offsetY + HEADER_HEIGHT,
@@ -355,7 +356,7 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
(HEADER_HEIGHT + LevelTerminalSection.TITLE_HEIGHT + 1.0f) / 256.0f, (HEADER_HEIGHT + LevelTerminalSection.TITLE_HEIGHT + 1.0f) / 256.0f,
xSize / 256.0f, xSize / 256.0f,
(HEADER_HEIGHT + 106.0f) / 256.0f); (HEADER_HEIGHT + 106.0f) / 256.0f);
Tessellator.instance.draw(); tess.draw();
/* Draw the bottom part */ /* Draw the bottom part */
drawTexturedModalRect(offsetX, offsetY + HEADER_HEIGHT + viewHeight, 0, 158, xSize, INV_HEIGHT); drawTexturedModalRect(offsetX, offsetY + HEADER_HEIGHT + viewHeight, 0, 158, xSize, INV_HEIGHT);
if (online) { if (online) {
@@ -483,7 +484,8 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
private int drawEntry(LevelTerminalEntry entry, int viewY, int titleBottom, int relMouseX, int relMouseY) { private int drawEntry(LevelTerminalEntry entry, int viewY, int titleBottom, int relMouseX, int relMouseY) {
final EntityPlayer player = Minecraft.getMinecraft().thePlayer; final EntityPlayer player = Minecraft.getMinecraft().thePlayer;
mc.getTextureManager().bindTexture(TEX_BG); mc.getTextureManager().bindTexture(TEX_BG);
Tessellator.instance.startDrawingQuads(); final Tessellator tess = Tessellator.instance;
tess.startDrawingQuads();
int relY = 0; int relY = 0;
final int slotLeftMargin = (VIEW_WIDTH - entry.rowSize * 18); final int slotLeftMargin = (VIEW_WIDTH - entry.rowSize * 18);
float lastZLevel = renderItem.zLevel; float lastZLevel = renderItem.zLevel;
@@ -512,7 +514,7 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
(173 + 18) / 256f); (173 + 18) / 256f);
} }
} }
Tessellator.instance.draw(); tess.draw();
/* Draw button */ /* Draw button */
if (viewY + entry.highlightButton.height > 0 && viewY < viewHeight) { if (viewY + entry.highlightButton.height > 0 && viewY < viewHeight) {
entry.highlightButton.yPosition = viewY + 1; entry.highlightButton.yPosition = viewY + 1;
@@ -316,9 +316,10 @@ public class PartFluidLevelEmitter extends PartUpgradeable implements IStackWatc
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void renderInventory(final IPartRenderHelper rh, final RenderBlocks renderer) { public void renderInventory(final IPartRenderHelper rh, final RenderBlocks renderer) {
rh.setTexture(this.getItemStack().getIconIndex()); rh.setTexture(this.getItemStack().getIconIndex());
Tessellator.instance.startDrawingQuads(); final Tessellator tess = Tessellator.instance;
tess.startDrawingQuads();
this.renderTorchAtAngle(0, -0.5, 0); this.renderTorchAtAngle(0, -0.5, 0);
Tessellator.instance.draw(); tess.draw();
} }
private void renderTorchAtAngle(double baseX, double baseY, double baseZ) { private void renderTorchAtAngle(double baseX, double baseY, double baseZ) {
@@ -366,21 +366,22 @@ public abstract class FCPart extends AEBasePart
rh.setBounds(2, 2, 14, 14, 14, 16); rh.setBounds(2, 2, 14, 14, 14, 16);
rh.renderBlock(x, y, z, renderer); rh.renderBlock(x, y, z, renderer);
final Tessellator tess = Tessellator.instance;
if (this.getLightLevel() > 0) { if (this.getLightLevel() > 0) {
final int l = 13; final int l = 13;
Tessellator.instance.setBrightness(l << 20 | l << 4); tess.setBrightness(l << 20 | l << 4);
} }
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = this renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = this
.getSpin(); .getSpin();
Tessellator.instance.setColorOpaque_I(this.getColor().whiteVariant); tess.setColorOpaque_I(this.getColor().whiteVariant);
rh.renderFace(x, y, z, this.getFrontBright().getIcon(), ForgeDirection.SOUTH, renderer); rh.renderFace(x, y, z, this.getFrontBright().getIcon(), ForgeDirection.SOUTH, renderer);
Tessellator.instance.setColorOpaque_I(this.getColor().mediumVariant); tess.setColorOpaque_I(this.getColor().mediumVariant);
rh.renderFace(x, y, z, this.getFrontDark().getIcon(), ForgeDirection.SOUTH, renderer); rh.renderFace(x, y, z, this.getFrontDark().getIcon(), ForgeDirection.SOUTH, renderer);
Tessellator.instance.setColorOpaque_I(this.getColor().blackVariant); tess.setColorOpaque_I(this.getColor().blackVariant);
rh.renderFace(x, y, z, this.getFrontColored().getIcon(), ForgeDirection.SOUTH, renderer); rh.renderFace(x, y, z, this.getFrontColored().getIcon(), ForgeDirection.SOUTH, renderer);
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0; renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;
@@ -404,15 +405,15 @@ public abstract class FCPart extends AEBasePart
if (hasChan) { if (hasChan) {
final int l = 14; final int l = 14;
Tessellator.instance.setBrightness(l << 20 | l << 4); tess.setBrightness(l << 20 | l << 4);
Tessellator.instance.setColorOpaque_I(this.getColor().blackVariant); tess.setColorOpaque_I(this.getColor().blackVariant);
} else if (hasPower) { } else if (hasPower) {
final int l = 9; final int l = 9;
Tessellator.instance.setBrightness(l << 20 | l << 4); tess.setBrightness(l << 20 | l << 4);
Tessellator.instance.setColorOpaque_I(this.getColor().whiteVariant); tess.setColorOpaque_I(this.getColor().whiteVariant);
} else { } else {
Tessellator.instance.setBrightness(0); tess.setBrightness(0);
Tessellator.instance.setColorOpaque_I(0x000000); tess.setColorOpaque_I(0x000000);
} }
final IIcon sideStatusLightTexture = CableBusTextures.PartMonitorSidesStatusLights.getIcon(); final IIcon sideStatusLightTexture = CableBusTextures.PartMonitorSidesStatusLights.getIcon();
@@ -399,21 +399,22 @@ public abstract class FCPartMonitor extends AbstractPartDisplay implements IPart
rh.setBounds(2, 2, 14, 14, 14, 16); rh.setBounds(2, 2, 14, 14, 14, 16);
rh.renderBlock(x, y, z, renderer); rh.renderBlock(x, y, z, renderer);
final Tessellator tess = Tessellator.instance;
if (this.getLightLevel() > 0) { if (this.getLightLevel() > 0) {
final int l = 13; final int l = 13;
Tessellator.instance.setBrightness(l << 20 | l << 4); tess.setBrightness(l << 20 | l << 4);
} }
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = this renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = this
.getSpin(); .getSpin();
Tessellator.instance.setColorOpaque_I(this.getColor().whiteVariant); tess.setColorOpaque_I(this.getColor().whiteVariant);
rh.renderFace(x, y, z, this.getFrontBright().getIcon(), ForgeDirection.SOUTH, renderer); rh.renderFace(x, y, z, this.getFrontBright().getIcon(), ForgeDirection.SOUTH, renderer);
Tessellator.instance.setColorOpaque_I(this.getColor().mediumVariant); tess.setColorOpaque_I(this.getColor().mediumVariant);
rh.renderFace(x, y, z, this.getFrontDark().getIcon(), ForgeDirection.SOUTH, renderer); rh.renderFace(x, y, z, this.getFrontDark().getIcon(), ForgeDirection.SOUTH, renderer);
Tessellator.instance.setColorOpaque_I(this.getColor().blackVariant); tess.setColorOpaque_I(this.getColor().blackVariant);
rh.renderFace(x, y, z, this.getFrontColored().getIcon(), ForgeDirection.SOUTH, renderer); rh.renderFace(x, y, z, this.getFrontColored().getIcon(), ForgeDirection.SOUTH, renderer);
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0; renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;
@@ -437,15 +438,15 @@ public abstract class FCPartMonitor extends AbstractPartDisplay implements IPart
if (hasChan) { if (hasChan) {
final int l = 14; final int l = 14;
Tessellator.instance.setBrightness(l << 20 | l << 4); tess.setBrightness(l << 20 | l << 4);
Tessellator.instance.setColorOpaque_I(this.getColor().blackVariant); tess.setColorOpaque_I(this.getColor().blackVariant);
} else if (hasPower) { } else if (hasPower) {
final int l = 9; final int l = 9;
Tessellator.instance.setBrightness(l << 20 | l << 4); tess.setBrightness(l << 20 | l << 4);
Tessellator.instance.setColorOpaque_I(this.getColor().whiteVariant); tess.setColorOpaque_I(this.getColor().whiteVariant);
} else { } else {
Tessellator.instance.setBrightness(0); tess.setBrightness(0);
Tessellator.instance.setColorOpaque_I(0x000000); tess.setColorOpaque_I(0x000000);
} }
final IIcon sideStatusLightTexture = CableBusTextures.PartMonitorSidesStatusLights.getIcon(); final IIcon sideStatusLightTexture = CableBusTextures.PartMonitorSidesStatusLights.getIcon();
@@ -27,20 +27,21 @@ public final class RenderUtil {
if (icon == null) { if (icon == null) {
return; return;
} }
Tessellator.instance.startDrawingQuads(); final Tessellator tess = Tessellator.instance;
Tessellator.instance.setNormal(nx, ny, nz); tess.startDrawingQuads();
tess.setNormal(nx, ny, nz);
if (nz > 0.0F) { if (nz > 0.0F) {
Tessellator.instance.addVertexWithUV(xStart, yStart, z, icon.getMinU(), icon.getMinV()); tess.addVertexWithUV(xStart, yStart, z, icon.getMinU(), icon.getMinV());
Tessellator.instance.addVertexWithUV(xEnd, yStart, z, icon.getMaxU(), icon.getMinV()); tess.addVertexWithUV(xEnd, yStart, z, icon.getMaxU(), icon.getMinV());
Tessellator.instance.addVertexWithUV(xEnd, yEnd, z, icon.getMaxU(), icon.getMaxV()); tess.addVertexWithUV(xEnd, yEnd, z, icon.getMaxU(), icon.getMaxV());
Tessellator.instance.addVertexWithUV(xStart, yEnd, z, icon.getMinU(), icon.getMaxV()); tess.addVertexWithUV(xStart, yEnd, z, icon.getMinU(), icon.getMaxV());
} else { } else {
Tessellator.instance.addVertexWithUV(xStart, yEnd, z, icon.getMinU(), icon.getMaxV()); tess.addVertexWithUV(xStart, yEnd, z, icon.getMinU(), icon.getMaxV());
Tessellator.instance.addVertexWithUV(xEnd, yEnd, z, icon.getMaxU(), icon.getMaxV()); tess.addVertexWithUV(xEnd, yEnd, z, icon.getMaxU(), icon.getMaxV());
Tessellator.instance.addVertexWithUV(xEnd, yStart, z, icon.getMaxU(), icon.getMinV()); tess.addVertexWithUV(xEnd, yStart, z, icon.getMaxU(), icon.getMinV());
Tessellator.instance.addVertexWithUV(xStart, yStart, z, icon.getMinU(), icon.getMinV()); tess.addVertexWithUV(xStart, yStart, z, icon.getMinU(), icon.getMinV());
} }
Tessellator.instance.draw(); tess.draw();
} }
public static void renderFluidIntoGui(Gui gui, int x, int y, int width, int height, public static void renderFluidIntoGui(Gui gui, int x, int y, int width, int height,