Performace fix for item rendering.

This commit is contained in:
RainWarrior 2015-11-07 12:58:23 +03:00
parent f466a0c387
commit 3d03461a52

View file

@ -8,6 +8,7 @@ import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.client.renderer.vertex.VertexFormatElement; import net.minecraft.client.renderer.vertex.VertexFormatElement;
import net.minecraft.client.renderer.vertex.VertexFormatElement.EnumUsage; import net.minecraft.client.renderer.vertex.VertexFormatElement.EnumUsage;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraftforge.client.ForgeHooksClient;
import net.minecraftforge.client.model.IColoredBakedQuad; import net.minecraftforge.client.model.IColoredBakedQuad;
import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheBuilder;
@ -236,7 +237,8 @@ public class LightUtil
return itemConsumer; return itemConsumer;
} }
public static void renderQuadColor(WorldRenderer wr, BakedQuad quad, int auxColor) // renders quad in any Vertex Format, but is slower
public static void renderQuadColorSlow(WorldRenderer wr, BakedQuad quad, int auxColor)
{ {
ItemConsumer cons; ItemConsumer cons;
if(wr == Tessellator.getInstance().getWorldRenderer()) if(wr == Tessellator.getInstance().getWorldRenderer())
@ -251,10 +253,24 @@ public class LightUtil
float g = (float)((auxColor >>> 8) & 0xFF) / 0xFF; float g = (float)((auxColor >>> 8) & 0xFF) / 0xFF;
float r = (float)((auxColor >>> 16) & 0xFF) / 0xFF; float r = (float)((auxColor >>> 16) & 0xFF) / 0xFF;
float a = (float)((auxColor >>> 24) & 0xFF) / 0xFF; float a = (float)((auxColor >>> 24) & 0xFF) / 0xFF;
cons.setAuxColor(r, g, b, a); cons.setAuxColor(r, g, b, a);
quad.pipe(cons); quad.pipe(cons);
} }
public static void renderQuadColor(WorldRenderer wr, BakedQuad quad, int auxColor)
{
wr.addVertexData(quad.getVertexData());
if(quad instanceof IColoredBakedQuad)
{
ForgeHooksClient.putQuadColor(wr, quad, auxColor);
}
else
{
wr.putColor4(auxColor);
}
}
public static class ItemConsumer extends VertexTransformer public static class ItemConsumer extends VertexTransformer
{ {
private boolean colored = false; private boolean colored = false;