下面列出了net.minecraft.util.IIcon#getMaxU ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public static void renderCore(EntityGolemBase golem, AdditionalGolemCore core) {
GL11.glPushMatrix();
GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F);
GL11.glTranslatef(0.0875F, -0.96F, 0.15F + (golem.getGolemDecoration().contains("P") ? 0.03F : 0.0F));
GL11.glScaled(0.175D, 0.175D, 0.175D);
GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
ItemStack coreItem = core.getItem();
IIcon icon = coreItem.getItem().getIcon(coreItem, 0);
float f1 = icon.getMaxU();
float f2 = icon.getMinV();
float f3 = icon.getMinU();
float f4 = icon.getMaxV();
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture);
ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f3, f4, icon.getIconWidth(), icon.getIconHeight(), 0.2F);
GL11.glPopMatrix();
}
private void renderIcon(IIcon icon) {
Tessellator tessellator = Tessellator.instance;
float minU = icon.getMinU();
float maxU = icon.getMaxU();
float minV = icon.getMinV();
float maxV = icon.getMaxV();
OpenGLHelper.rotate(180.0F - renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
OpenGLHelper.rotate(-renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 1.0F, 0.0F);
tessellator.addVertexWithUV(-0.5F, -0.25F, 0.0D, minU, maxV);
tessellator.addVertexWithUV(0.5F, -0.25F, 0.0D, maxU, maxV);
tessellator.addVertexWithUV(0.5F, 0.75F, 0.0D, maxU, minV);
tessellator.addVertexWithUV(-0.5F, 0.75F, 0.0D, minU, minV);
tessellator.draw();
}
void side(int a, int b, int c, int d, int iconIndex, boolean flip)
{
IIcon icon = iconIndex >= 16 ? submapSmall.icons[iconIndex - 16] : submap.icons[iconIndex];
double u0 = icon.getMaxU();
double u1 = icon.getMinU();
double v0 = icon.getMaxV();
double v1 = icon.getMinV();
U[a] = flip ? u1 : u1;
U[b] = flip ? u0 : u1;
U[c] = flip ? u0 : u0;
U[d] = flip ? u1 : u0;
V[a] = flip ? v1 : v1;
V[b] = flip ? v1 : v0;
V[c] = flip ? v0 : v0;
V[d] = flip ? v0 : v1;
vert(a);
vert(b);
vert(c);
vert(d);
}
@Override
protected void drawProgressBar(Tessellator tessellator, TextureManager renderEngine, int barMinX, int barMaxX, int barMinY, int barMaxY, int zLevel) {
IIcon progressBarIcon = getProgressBarIcon();
if(progressBarIcon == null) {
return;
}
double minU = progressBarIcon.getMinU();
double minV = progressBarIcon.getMinV();
double maxU = progressBarIcon.getMaxU();
double maxV = progressBarIcon.getMaxV();
renderEngine.bindTexture(getResourceLocation());
// Draw the bar in 16-pixel slices from the bottom up.
for(int slicedBarY = barMaxY; slicedBarY > 0; slicedBarY -= 16) {
int slicedBarHeight = (int)Math.min(slicedBarY - barMinY, 16.0f);
tessellator.startDrawingQuads();
tessellator.addVertexWithUV(barMinX, slicedBarY, zLevel, minU, minV + (maxV - minV) * slicedBarHeight / 16.0f);
tessellator.addVertexWithUV(barMaxX, slicedBarY, zLevel, maxU, minV + (maxV - minV) * slicedBarHeight / 16.0f);
tessellator.addVertexWithUV(barMaxX, slicedBarY - slicedBarHeight, zLevel, maxU, minV);
tessellator.addVertexWithUV(barMinX, slicedBarY - slicedBarHeight, zLevel, minU, minV);
tessellator.draw();
}
}
void set(double x, double y, double z, IIcon icon, IIcon icon1, IIcon icon2) {
tessellator = Tessellator.instance;
i0u0 = icon.getMinU();
i0uh = icon.getInterpolatedU(8.0D);
i0u1 = icon.getMaxU();
i0v0 = icon.getMinV();
i0v1 = icon.getMaxV();
i1u0 = icon1.getInterpolatedU(7.0D);
i1u1 = icon1.getInterpolatedU(9.0D);
i1v0 = icon1.getMinV();
i1vh = icon1.getInterpolatedV(8.0D);
i1v1 = icon1.getMaxV();
i1v = i1v1 - i1v0;
i2u0 = icon2.getInterpolatedU(7.0D);
i2u1 = icon2.getInterpolatedU(9.0D);
i2v0 = icon2.getMinV();
i2v1 = icon2.getMaxV();
i2v = i2v1 - i2v0;
x0 = x;
xh = x0 + 0.5D;
x1 = x + 1;
xp0 = x0 + 0.5D - 0.0625D;
xp1 = x0 + 0.5D + 0.0625D;
z0 = z;
zh = z0 + 0.5D;
z1 = z + 1;
zp0 = z0 + 0.5D - 0.0625D;
zp1 = z0 + 0.5D + 0.0625D;
y0 = y;
y1 = y + 1;
}
void drawSpike(IIcon icon, double r, double h, double x, double y, double z, double dx, double dz)
{
Tessellator tessellator = Tessellator.instance;
double u0 = icon.getMinU();
double u1 = icon.getMaxU();
double v0 = icon.getMaxV();
double v1 = icon.getMinV();
double tx = x + dx;
double ty = y + h;
double tz = z + dz;
tessellator.addVertexWithUV(x + r, y + 0, z + r, u0, v0);
tessellator.addVertexWithUV(x + r, y + 0, z - r, u1, v0);
tessellator.addVertexWithUV(tx, ty, tz, u1, v1);
tessellator.addVertexWithUV(tx, ty, tz, u0, v1);
tessellator.addVertexWithUV(x - r, y + 0, z + r, u1, v0);
tessellator.addVertexWithUV(x + r, y + 0, z + r, u0, v0);
tessellator.addVertexWithUV(tx, ty, tz, u1, v1);
tessellator.addVertexWithUV(tx, ty, tz, u0, v1);
tessellator.addVertexWithUV(x + r, y + 0, z - r, u1, v0);
tessellator.addVertexWithUV(x - r, y + 0, z - r, u0, v0);
tessellator.addVertexWithUV(tx, ty, tz, u1, v1);
tessellator.addVertexWithUV(tx, ty, tz, u0, v1);
tessellator.addVertexWithUV(x - r, y + 0, z - r, u1, v0);
tessellator.addVertexWithUV(x - r, y + 0, z + r, u0, v0);
tessellator.addVertexWithUV(tx, ty, tz, u1, v1);
tessellator.addVertexWithUV(tx, ty, tz, u0, v1);
}
void set(double x, double y, double z, IIcon icon, IIcon icon1, IIcon icon2)
{
tessellator = Tessellator.instance;
i0u0 = icon.getMinU();
i0uh = icon.getInterpolatedU(8.0D);
i0u1 = icon.getMaxU();
i0v0 = icon.getMinV();
i0v1 = icon.getMaxV();
i1u0 = icon1.getInterpolatedU(7.0D);
i1u1 = icon1.getInterpolatedU(9.0D);
i1v0 = icon1.getMinV();
i1vh = icon1.getInterpolatedV(8.0D);
i1v1 = icon1.getMaxV();
i1v = i1v1 - i1v0;
i2u0 = icon2.getInterpolatedU(7.0D);
i2u1 = icon2.getInterpolatedU(9.0D);
i2v0 = icon2.getMinV();
i2v1 = icon2.getMaxV();
i2v = i2v1 - i2v0;
x0 = x;
xh = x0 + 0.5D;
x1 = x + 1;
xp0 = x0 + 0.5D - 0.0625D;
xp1 = x0 + 0.5D + 0.0625D;
z0 = z;
zh = z0 + 0.5D;
z1 = z + 1;
zp0 = z0 + 0.5D - 0.0625D;
zp1 = z0 + 0.5D + 0.0625D;
y0 = y;
y1 = y + 1;
}
public static void drawTexturedQuad(double x, double y, IIcon icon, float width, float height, float uMax, float vMax) {
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
float textureU = icon.getMinU() + (icon.getMaxU() - icon.getMinU()) * uMax;
float textureV = icon.getMinV() + (icon.getMaxV() - icon.getMinV()) * vMax;
tessellator.addVertexWithUV(x + 0, y + height, 0D, icon.getMinU(), textureV);
tessellator.addVertexWithUV(x + width, y + height, 0D, textureU, textureV);
tessellator.addVertexWithUV(x + width, y + 0, 0D, textureU, icon.getMinV());
tessellator.addVertexWithUV(x + 0, y + 0, 0D, icon.getMinU(), icon.getMinV());
tessellator.draw();
}
void setupSides(IIcon icon, int a, int b, int c, int d, int e, int ta, int tb, int tc, int td) {
L[a] = brightnessBottomLeft;
L[b] = brightnessBottomRight;
L[c] = brightnessTopRight;
L[d] = brightnessTopLeft;
L[e] = (brightnessBottomLeft + brightnessTopLeft + brightnessTopRight + brightnessBottomRight) / 4;
R[a] = colorRedBottomLeft;
R[b] = colorRedBottomRight;
R[c] = colorRedTopRight;
R[d] = colorRedTopLeft;
R[e] = (colorRedBottomLeft + colorRedTopLeft + colorRedTopRight + colorRedBottomRight) / 4;
G[a] = colorGreenBottomLeft;
G[b] = colorGreenBottomRight;
G[c] = colorGreenTopRight;
G[d] = colorGreenTopLeft;
G[e] = (colorGreenBottomLeft + colorGreenTopLeft + colorGreenTopRight + colorGreenBottomRight) / 4;
B[a] = colorBlueBottomLeft;
B[b] = colorBlueBottomRight;
B[c] = colorBlueTopRight;
B[d] = colorBlueTopLeft;
B[e] = (colorBlueBottomLeft + colorBlueTopLeft + colorBlueTopRight + colorBlueBottomRight) / 4;
double u0 = icon.getMaxU();
double u1 = icon.getMinU();
double v0 = icon.getMaxV();
double v1 = icon.getMinV();
U[ta] = u0;
U[tb] = u0;
U[tc] = u1;
U[td] = u1;
U[e] = icon.getInterpolatedU(8.0D);
V[ta] = v0;
V[tb] = v1;
V[tc] = v1;
V[td] = v0;
V[e] = icon.getInterpolatedV(8.0D);
}
private void getIconUV (IIcon icon, double[] uv) {
uv[0] = icon.getMinU();
uv[1] = icon.getMinV();
uv[2] = icon.getMaxU();
uv[3] = icon.getMaxV();
}
@Override
public void render (IBlockAccess world, int x, int y, int z, RenderBlocks renderer, Block block, int meta, int height, AxisAlignedBB[] bounds) {
if (!(block instanceof BlockDoublePlant))
return;
plantRender.render(world, x, y, z, renderer, block, meta, height, bounds);
if (height != 2)
return;
Tessellator tessellator = Tessellator.instance;
double orientation = Math.cos((double)0 * 0.8D) * Math.PI * 0.1D;
double aCos = Math.cos(orientation);
double aSin = Math.sin(orientation);
double xTR = 0.5D + 0.3D * aCos - 0.5D * aSin;
double zTR = 0.5D + 0.5D * aCos + 0.3D * aSin;
double xTL = 0.5D + 0.3D * aCos + 0.5D * aSin;
double ZTL = 0.5D + -0.5D * aCos + 0.3D * aSin;
double xBL = 0.5D + -0.05D * aCos + 0.5D * aSin;
double zBL = 0.5D + -0.5D * aCos + -0.05D * aSin;
double xBR = 0.5D + -0.05D * aCos - 0.5D * aSin;
double zBR = 0.5D + 0.5D * aCos + -0.05D * aSin;
IIcon icon = Blocks.double_plant.sunflowerIcons[0];
double iconMinU = icon.getMinU();
double iconMinV = icon.getMinV();
double iconMaxU = icon.getMaxU();
double iconMaxV = icon.getMaxV();
tessellator.addVertexWithUV(x + xBL, y + 1.0D, z + zBL, iconMinU, iconMaxV);
tessellator.addVertexWithUV(x + xBR, y + 1.0D, z + zBR, iconMaxU, iconMaxV);
tessellator.addVertexWithUV(x + xTR, y + 0.0D, z + zTR, iconMaxU, iconMinV);
tessellator.addVertexWithUV(x + xTL, y + 0.0D, z + ZTL, iconMinU, iconMinV);
icon = Blocks.double_plant.sunflowerIcons[1];
iconMinU = icon.getMinU();
iconMinV = icon.getMinV();
iconMaxU = icon.getMaxU();
iconMaxV = icon.getMaxV();
tessellator.addVertexWithUV(x + xBR, y + 1.0D, z + zBR, iconMinU, iconMaxV);
tessellator.addVertexWithUV(x + xBL, y + 1.0D, z + zBL, iconMaxU, iconMaxV);
tessellator.addVertexWithUV(x + xTL, y + 0.0D, z + ZTL, iconMaxU, iconMinV);
tessellator.addVertexWithUV(x + xTR, y + 0.0D, z + zTR, iconMinU, iconMinV);
}
private boolean renderBlockDoublePlant(IBlockAccess world, RenderBlocks renderer, BlockDoublePlant block, int x, int y, int z, TileEntityGarden potData)
{
Tessellator tessellator = Tessellator.instance;
tessellator.setBrightness(block.getMixedBrightnessForBlock(renderer.blockAccess, x, y, z));
int l = block.colorMultiplier(renderer.blockAccess, x, y, z);
//if (l == world.getBiomeGenForCoords(x, z).getBiomeGrassColor(x, y, z))
// l = ColorizerGrass.getGrassColor(potData.getBiomeTemperature(), potData.getBiomeHumidity());
float f = (float)(l >> 16 & 255) / 255.0F;
float f1 = (float)(l >> 8 & 255) / 255.0F;
float f2 = (float)(l & 255) / 255.0F;
if (EntityRenderer.anaglyphEnable)
{
float f3 = (f * 30.0F + f1 * 59.0F + f2 * 11.0F) / 100.0F;
float f4 = (f * 30.0F + f1 * 70.0F) / 100.0F;
float f5 = (f * 30.0F + f2 * 70.0F) / 100.0F;
f = f3;
f1 = f4;
f2 = f5;
}
tessellator.setColorOpaque_F(f, f1, f2);
long j1 = (long)(x * 3129871) ^ (long)z * 116129781L;
j1 = j1 * j1 * 42317861L + j1 * 11L;
double d19 = (double)x;
double d0 = (double)y;
double d1 = (double)z;
//d19 += ((double)((float)(j1 >> 16 & 15L) / 15.0F) - 0.5D) * 0.3D;
//d1 += ((double)((float)(j1 >> 24 & 15L) / 15.0F) - 0.5D) * 0.3D;
int i1 = renderer.blockAccess.getBlockMetadata(x, y, z);
boolean flag = false;
boolean flag1 = BlockDoublePlant.func_149887_c(i1);
int k1;
if (flag1)
{
k1 = BlockDoublePlant.func_149890_d(renderer.blockAccess.getBlockMetadata(x, y - 1, z));
}
else
{
k1 = BlockDoublePlant.func_149890_d(i1);
}
IIcon iicon = block.func_149888_a(flag1, k1);
renderer.drawCrossedSquares(iicon, d19, d0, d1, 1.0F);
if (flag1 && k1 == 0)
{
IIcon iicon1 = block.sunflowerIcons[0];
double d2 = Math.cos((double)j1 * 0.8D) * Math.PI * 0.1D;
double d3 = Math.cos(d2);
double d4 = Math.sin(d2);
double d5 = (double)iicon1.getMinU();
double d6 = (double)iicon1.getMinV();
double d7 = (double)iicon1.getMaxU();
double d8 = (double)iicon1.getMaxV();
double d9 = 0.3D;
double d10 = -0.05D;
double d11 = 0.5D + 0.3D * d3 - 0.5D * d4;
double d12 = 0.5D + 0.5D * d3 + 0.3D * d4;
double d13 = 0.5D + 0.3D * d3 + 0.5D * d4;
double d14 = 0.5D + -0.5D * d3 + 0.3D * d4;
double d15 = 0.5D + -0.05D * d3 + 0.5D * d4;
double d16 = 0.5D + -0.5D * d3 + -0.05D * d4;
double d17 = 0.5D + -0.05D * d3 - 0.5D * d4;
double d18 = 0.5D + 0.5D * d3 + -0.05D * d4;
tessellator.addVertexWithUV(d19 + d15, d0 + 1.0D, d1 + d16, d5, d8);
tessellator.addVertexWithUV(d19 + d17, d0 + 1.0D, d1 + d18, d7, d8);
tessellator.addVertexWithUV(d19 + d11, d0 + 0.0D, d1 + d12, d7, d6);
tessellator.addVertexWithUV(d19 + d13, d0 + 0.0D, d1 + d14, d5, d6);
IIcon iicon2 = block.sunflowerIcons[1];
d5 = (double)iicon2.getMinU();
d6 = (double)iicon2.getMinV();
d7 = (double)iicon2.getMaxU();
d8 = (double)iicon2.getMaxV();
tessellator.addVertexWithUV(d19 + d17, d0 + 1.0D, d1 + d18, d5, d8);
tessellator.addVertexWithUV(d19 + d15, d0 + 1.0D, d1 + d16, d7, d8);
tessellator.addVertexWithUV(d19 + d13, d0 + 0.0D, d1 + d14, d7, d6);
tessellator.addVertexWithUV(d19 + d11, d0 + 0.0D, d1 + d12, d5, d6);
}
return true;
}
private boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, BlockSmallFire block, int modelId, RenderBlocks renderer) {
Tessellator tessellator = Tessellator.instance;
IIcon icon0 = block.getFireIcon(0);
IIcon icon1 = block.getFireIcon(1);
IIcon icon2 = icon0;
if (renderer.hasOverrideBlockTexture())
icon2 = renderer.overrideBlockTexture;
tessellator.setColorOpaque_F(1, 1, 1);
tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
double uMin = icon2.getMinU();
double vMin = icon2.getMinV();
double uMax = icon2.getMaxU();
double vMax = icon2.getMaxV();
double y0 = y - .0625;
double y1 = y + 1;
double x0 = x + .5 + .2;
double x1 = x + .5 - .2;
double x2 = x + .5 - .3;
double x3 = x + .5 + .3;
double z0 = z + .5 + .2;
double z1 = z + .5 - .2;
double z2 = z + .5 - .3;
double z3 = z + .5 + .3;
tessellator.addVertexWithUV(x2, y1, z + 1 - .0625f, uMax, vMin);
tessellator.addVertexWithUV(x0, y0, z + 1 - .0625f, uMax, vMax);
tessellator.addVertexWithUV(x0, y0, z + 0 + .0625f, uMin, vMax);
tessellator.addVertexWithUV(x2, y1, z + 0 + .0625f, uMin, vMin);
tessellator.addVertexWithUV(x3, y1, z + 0 + .0625f, uMax, vMin);
tessellator.addVertexWithUV(x1, y0, z + 0 + .0625f, uMax, vMax);
tessellator.addVertexWithUV(x1, y0, z + 1 - .0625f, uMin, vMax);
tessellator.addVertexWithUV(x3, y1, z + 1 - .0625f, uMin, vMin);
uMin = icon1.getMinU();
vMin = icon1.getMinV();
uMax = icon1.getMaxU();
vMax = icon1.getMaxV();
tessellator.addVertexWithUV(x + 1 - .0625f, y1, z3, uMax, vMin);
tessellator.addVertexWithUV(x + 1 - .0625f, y0, z1, uMax, vMax);
tessellator.addVertexWithUV(x + 0 + .0625f, y0, z1, uMin, vMax);
tessellator.addVertexWithUV(x + 0 + .0625f, y1, z3, uMin, vMin);
tessellator.addVertexWithUV(x + 0 + .0625f, y1, z2, uMax, vMin);
tessellator.addVertexWithUV(x + 0 + .0625f, y0, z0, uMax, vMax);
tessellator.addVertexWithUV(x + 1 - .0625f, y0, z0, uMin, vMax);
tessellator.addVertexWithUV(x + 1 - .0625f, y1, z2, uMin, vMin);
x0 = x + .5 - .5 + .125f;
x1 = x + .5 + .5 - .125f;
x2 = x + .5 - .4 + .125f;
x3 = x + .5 + .4 - .125f;
z0 = z + .5 - .5 + .125f;
z1 = z + .5 + .5 - .125f;
z2 = z + .5 - .4 + .125f;
z3 = z + .5 + .4 - .125f;
tessellator.addVertexWithUV(x2, y1, z + 0, uMax, vMin);
tessellator.addVertexWithUV(x0, y0, z + 0, uMax, vMax);
tessellator.addVertexWithUV(x0, y0, z + 1, uMin, vMax);
tessellator.addVertexWithUV(x2, y1, z + 1, uMin, vMin);
tessellator.addVertexWithUV(x3, y1, z + 1, uMax, vMin);
tessellator.addVertexWithUV(x1, y0, z + 1, uMax, vMax);
tessellator.addVertexWithUV(x1, y0, z + 0, uMin, vMax);
tessellator.addVertexWithUV(x3, y1, z + 0, uMin, vMin);
uMin = icon0.getMinU();
vMin = icon0.getMinV();
uMax = icon0.getMaxU();
vMax = icon0.getMaxV();
tessellator.addVertexWithUV(x + 0, y1, z3, uMax, vMin);
tessellator.addVertexWithUV(x + 0, y0, z1, uMax, vMax);
tessellator.addVertexWithUV(x + 1, y0, z1, uMin, vMax);
tessellator.addVertexWithUV(x + 1, y1, z3, uMin, vMin);
tessellator.addVertexWithUV(x + 1, y1, z2, uMax, vMin);
tessellator.addVertexWithUV(x + 1, y0, z0, uMax, vMax);
tessellator.addVertexWithUV(x + 0, y0, z0, uMin, vMax);
tessellator.addVertexWithUV(x + 0, y1, z2, uMin, vMin);
return true;
}
private void drawBetween (RenderBlocks renderer, IIcon icon, double x0, double y0, double z0, double x1, double y1, double z1) {
Tessellator tessellator = Tessellator.instance;
double minU = icon.getMinU();
double minV = icon.getMinV();
double maxU = icon.getMaxU();
double maxV = icon.getMaxV();
Vec3 vT = Vec3.createVectorHelper(x1 - x0, y1 - y0, z1 - z0);
Vec3 vB = Vec3.createVectorHelper(x1 - x0, 0, z1 - z0);
Vec3 vN = vT.crossProduct(vB);
Vec3 vU = vT.crossProduct(vN);
vU = vU.normalize();
vN = vN.normalize();
double vUx = vU.xCoord / 2;
double vUy = vU.yCoord / 2;
double vUz = vU.zCoord / 2;
if (vUx == 0 && vUy == 0) {
vUx = -.5;
vUz = .5;
}
tessellator.addVertexWithUV(x0 + vUx, y0 + vUy, z0 + vUz, maxU, minV);
tessellator.addVertexWithUV(x0 - vUx, y0 - vUy, z0 - vUz, minU, minV);
tessellator.addVertexWithUV(x1 - vUx, y1 - vUy, z1 - vUz, minU, maxV);
tessellator.addVertexWithUV(x1 + vUx, y1 + vUy, z1 + vUz, maxU, maxV);
tessellator.addVertexWithUV(x1 + vUx, y1 + vUy, z1 + vUz, maxU, maxV);
tessellator.addVertexWithUV(x1 - vUx, y1 - vUy, z1 - vUz, minU, maxV);
tessellator.addVertexWithUV(x0 - vUx, y0 - vUy, z0 - vUz, minU, minV);
tessellator.addVertexWithUV(x0 + vUx, y0 + vUy, z0 + vUz, maxU, minV);
double vNx = vN.xCoord / 2;
double vNy = vN.yCoord / 2;
double vNz = vN.zCoord / 2;
if (vNx == 0 && vNy == 0) {
vNx = .5;
vNz = .5;
}
tessellator.addVertexWithUV(x0 + vNx, y0 + vNy, z0 + vNz, maxU, minV);
tessellator.addVertexWithUV(x0 - vNx, y0 - vNy, z0 - vNz, minU, minV);
tessellator.addVertexWithUV(x1 - vNx, y1 - vNy, z1 - vNz, minU, maxV);
tessellator.addVertexWithUV(x1 + vNx, y1 + vNy, z1 + vNz, maxU, maxV);
tessellator.addVertexWithUV(x1 + vNx, y1 + vNy, z1 + vNz, maxU, maxV);
tessellator.addVertexWithUV(x1 - vNx, y1 - vNy, z1 - vNz, minU, maxV);
tessellator.addVertexWithUV(x0 - vNx, y0 - vNy, z0 - vNz, minU, minV);
tessellator.addVertexWithUV(x0 + vNx, y0 + vNy, z0 + vNz, maxU, minV);
}
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer)
{
Tessellator tessellator = Tessellator.instance;
int l = world.getBlockMetadata(x, y, z);
IIcon iicon = renderer.getBlockIconFromSideAndMetadata(block, 0, l);
int dir = l & 3;
tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F);
double u0 = iicon.getMinU();
double v0 = iicon.getMinV();
double u1 = iicon.getMaxU();
double v1 = iicon.getMaxV();
double yoffset = 0.0625D;
double dx = x + 1;
double dz = z + 1;
double dy = y + yoffset;
switch (dir)
{
case 0:
tessellator.addVertexWithUV(x, dy, z, u1, v1);
tessellator.addVertexWithUV(x, dy, dz, u1, v0);
tessellator.addVertexWithUV(dx, dy, dz, u0, v0);
tessellator.addVertexWithUV(dx, dy, z, u0, v1);
break;
case 1:
tessellator.addVertexWithUV(x, dy, z, u1, v0);
tessellator.addVertexWithUV(x, dy, dz, u0, v0);
tessellator.addVertexWithUV(dx, dy, dz, u0, v1);
tessellator.addVertexWithUV(dx, dy, z, u1, v1);
break;
case 2:
tessellator.addVertexWithUV(x, dy, z, u0, v0);
tessellator.addVertexWithUV(x, dy, dz, u0, v1);
tessellator.addVertexWithUV(dx, dy, dz, u1, v1);
tessellator.addVertexWithUV(dx, dy, z, u1, v0);
break;
case 3:
default:
tessellator.addVertexWithUV(x, dy, z, u0, v1);
tessellator.addVertexWithUV(x, dy, dz, u1, v1);
tessellator.addVertexWithUV(dx, dy, dz, u1, v0);
tessellator.addVertexWithUV(dx, dy, z, u0, v0);
}
return true;
}
void setupSides(IIcon icon, int a, int b, int c, int d, int e, int ta, int tb, int tc, int td)
{
L[a] = brightnessBottomLeft;
L[b] = brightnessBottomRight;
L[c] = brightnessTopRight;
L[d] = brightnessTopLeft;
L[e] = (brightnessBottomLeft + brightnessTopLeft + brightnessTopRight + brightnessBottomRight) / 4;
R[a] = colorRedBottomLeft;
R[b] = colorRedBottomRight;
R[c] = colorRedTopRight;
R[d] = colorRedTopLeft;
R[e] = (colorRedBottomLeft + colorRedTopLeft + colorRedTopRight + colorRedBottomRight) / 4;
G[a] = colorGreenBottomLeft;
G[b] = colorGreenBottomRight;
G[c] = colorGreenTopRight;
G[d] = colorGreenTopLeft;
G[e] = (colorGreenBottomLeft + colorGreenTopLeft + colorGreenTopRight + colorGreenBottomRight) / 4;
B[a] = colorBlueBottomLeft;
B[b] = colorBlueBottomRight;
B[c] = colorBlueTopRight;
B[d] = colorBlueTopLeft;
B[e] = (colorBlueBottomLeft + colorBlueTopLeft + colorBlueTopRight + colorBlueBottomRight) / 4;
double u0 = icon.getMaxU();
double u1 = icon.getMinU();
double v0 = icon.getMaxV();
double v1 = icon.getMinV();
U[ta] = u0;
U[tb] = u0;
U[tc] = u1;
U[td] = u1;
U[e] = icon.getInterpolatedU(8.0D);
V[ta] = v0;
V[tb] = v1;
V[tc] = v1;
V[td] = v0;
V[e] = icon.getInterpolatedV(8.0D);
}
public static void genBlockColours(BlockColours bc) {
MwUtil.log("generating block map colours from textures");
// copy terrain texture to MwRender pixel bytebuffer
// bind the terrain texture
//Minecraft.getMinecraft().func_110434_K().func_110577_a(TextureMap.field_110575_b);
// get the bound texture id
//int terrainTextureId = Render.getBoundTextureId();
int terrainTextureId = Minecraft.getMinecraft().renderEngine.getTexture(TextureMap.locationBlocksTexture).getGlTextureId();
// create texture object from the currently bound GL texture
if (terrainTextureId == 0) {
MwUtil.log("error: could get terrain texture ID");
return;
}
Texture terrainTexture = new Texture(terrainTextureId);
double u1Last = 0;
double u2Last = 0;
double v1Last = 0;
double v2Last = 0;
int blockColourLast = 0;
int e_count = 0;
int b_count = 0;
int s_count = 0;
for (int blockID = 0; blockID < 4096; blockID++) { //TODO: replace hardcoded 4096 with actual registry size
for (int dv = 0; dv < 16; dv++) {
int blockAndMeta = ((blockID & 0xfff) << 4) | (dv & 0xf);
Block block = (Block) Block.blockRegistry.getObjectById(blockID);
int blockColour = 0;
if (block != null) {
IIcon icon = null;
try {
icon = block.getIcon(1, dv);
} catch (Exception e) {
//MwUtil.log("genFromTextures: exception caught when requesting block texture for %03x:%x", blockID, dv);
//e.printStackTrace();
e_count++;
}
if (icon != null) {
double u1 = icon.getMinU();
double u2 = icon.getMaxU();
double v1 = icon.getMinV();
double v2 = icon.getMaxV();
if ((u1 == u1Last) && (u2 == u2Last) && (v1 == v1Last) && (v2 == v2Last)) {
blockColour = blockColourLast;
s_count++;
} else {
blockColour = getIconMapColour(icon, terrainTexture);
u1Last = u1;
u2Last = u2;
v1Last = v1;
v2Last = v2;
blockColourLast = blockColour;
b_count++;
}
//if (dv == 0)
// MwUtil.log("block %03x:%x colour = %08x", blockID, dv, blockColour);
}
// doesn't work as some leaves blocks aren't rendered using the biome
// foliage colour
//try {
// if (block.isLeaves(null, 0, 0, 0)) {
// bc.setBlockType(blockAndMeta, BlockType.LEAVES);
// }
//} catch (NullPointerException e) {
//}
blockColour = adjustBlockColourFromType(bc, blockAndMeta, blockColour);
}
bc.setColour(blockAndMeta, blockColour);
}
}
MwUtil.log("processed %d block textures, %d skipped, %d exceptions", b_count, s_count, e_count);
genBiomeColours(bc);
}