Skip to content

Instantly share code, notes, and snippets.

@magnifikus
Created December 7, 2012 15:22
Show Gist options
  • Save magnifikus/4233911 to your computer and use it in GitHub Desktop.
Save magnifikus/4233911 to your computer and use it in GitHub Desktop.
package de.squig.plc.client.renderer;
import java.nio.FloatBuffer;
import net.minecraft.src.TileEntity;
import net.minecraft.src.TileEntitySpecialRenderer;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11;
import de.squig.plc.tile.TileController;
public class TEControllerRenderer extends TileEntitySpecialRenderer {
private FloatBuffer working = BufferUtils.createFloatBuffer(4);
@Override
public void renderTileEntityAt(TileEntity tile, double x, double y,
double z, float f) {
TileController topview = (TileController) tile;
GL11.glPushMatrix();
// @TODO side impl
int side = 3;
float dx = 1F / 16;
float dz = 1F / 16;
float displayWidth = 1 - 2F / 16;
float displayHeight = 1 - 2F / 16;
GL11.glTranslatef((float) x, (float) y, (float) z);
switch (side) {
case 1:
break;
case 0:
GL11.glTranslatef(1, 1, 0);
GL11.glRotatef(180, 1, 0, 0);
GL11.glRotatef(180, 0, 1, 0);
break;
case 3:
GL11.glTranslatef(0, 1, 0);
GL11.glRotatef(0, 0, 1, 0);
GL11.glRotatef(90, 1, 0, 0);
break;
case 2:
GL11.glTranslatef(1, 1, 1);
GL11.glRotatef(180, 0, 1, 0);
GL11.glRotatef(90, 1, 0, 0);
break;
case 5:
GL11.glTranslatef(0, 1, 1);
GL11.glRotatef(90, 0, 1, 0);
GL11.glRotatef(90, 1, 0, 0);
break;
case 4:
GL11.glTranslatef(1, 1, 0);
GL11.glRotatef(-90, 0, 1, 0);
GL11.glRotatef(90, 1, 0, 0);
break;
}
GL11.glTranslatef(dx + displayWidth / 2, 1F, dz + displayHeight / 2);
GL11.glRotatef(-90, 1, 0, 0);
float topLeft = -0.5f;
float unit = 1 / 16f;
GL11.glDisable(GL11.GL_LIGHTING);
bindTextureByName("/ressources/art/gui/blocks.png");
//GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glBegin(GL11.GL_QUADS);
GL11.glTexCoord2f(0,0);
GL11.glVertex3f(topLeft + 16 * unit, topLeft + 13 * unit, 0.1f); // The
// top
// right
GL11.glTexCoord2f(0,1); // corner
GL11.glVertex3f(topLeft + 16 * unit, topLeft + 16 * unit, 0.1f); // The
// top
// right
GL11.glTexCoord2f(1,1); // corner
GL11.glVertex3f(topLeft + 13 * unit, topLeft + 16 * unit, 0.1f); // The
// top
// right
GL11.glTexCoord2f(1,0); // corner
GL11.glVertex3f(topLeft + 13 * unit, topLeft + 13 * unit, 0.1f); // The
// top
// right
// corner
GL11.glEnd();
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glDepthMask(true);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL);
GL11.glPopMatrix();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment