Skip to content

Instantly share code, notes, and snippets.

@ThexXTURBOXx
Created June 1, 2017 12:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThexXTURBOXx/04eb325a7c90811e24b975ac94975634 to your computer and use it in GitHub Desktop.
Save ThexXTURBOXx/04eb325a7c90811e24b975ac94975634 to your computer and use it in GitHub Desktop.
package de.Femtopedia.XYCraftRL.client;
import org.lwjgl.opengl.GL11;
import de.Femtopedia.XYCraftRL.TileEntityGlow;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
public class GlowTESR extends TileEntitySpecialRenderer<TileEntityGlow> {
@Override
public void renderTileEntityAt(TileEntityGlow te, double x, double y, double z, float partialTicks, int destroyStage) {
for(int i = 0; i < te.layers.size(); i++) {
GL11.glPushMatrix();
GlStateManager.translate(x, y, z);
GlStateManager.enableCull();
if(!te.light.get(i)) {
GlStateManager.pushAttrib();
GlStateManager.enableLighting();
GL11.glEnable(GL11.GL_LIGHTING);
Minecraft.getMinecraft().entityRenderer.enableLightmap();
}
float cx = te.coordX.get(i);
float cy = te.coordY.get(i);
float maxx = te.maxX.get(i);
float maxy = te.maxY.get(i);
Minecraft.getMinecraft().renderEngine.bindTexture(te.layers.get(i));
Tessellator tessellator = Tessellator.getInstance();
tessellator.getBuffer().begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
//NORTH
tessellator.getBuffer().pos(0, 1, 0).tex(cx, cy + maxy).endVertex();
tessellator.getBuffer().pos(1, 1, 0).tex(cx + maxx, cy + maxy).endVertex();
tessellator.getBuffer().pos(1, 0, 0).tex(cx + maxx, cy).endVertex();
tessellator.getBuffer().pos(0, 0, 0).tex(cx, cy).endVertex();
//SOUTH
tessellator.getBuffer().pos(1, 1, 1).tex(cx, cy + maxy).endVertex();
tessellator.getBuffer().pos(0, 1, 1).tex(cx + maxx, cy + maxy).endVertex();
tessellator.getBuffer().pos(0, 0, 1).tex(cx + maxx, cy).endVertex();
tessellator.getBuffer().pos(1, 0, 1).tex(cx, cy).endVertex();
//EAST
tessellator.getBuffer().pos(1, 1, 0).tex(cx, cy + maxy).endVertex();
tessellator.getBuffer().pos(1, 1, 1).tex(cx + maxx, cy + maxy).endVertex();
tessellator.getBuffer().pos(1, 0, 1).tex(cx + maxx, cy).endVertex();
tessellator.getBuffer().pos(1, 0, 0).tex(cx, cy).endVertex();
//WEST
tessellator.getBuffer().pos(0, 1, 1).tex(cx, cy + maxy).endVertex();
tessellator.getBuffer().pos(0, 1, 0).tex(cx + maxx, cy + maxy).endVertex();
tessellator.getBuffer().pos(0, 0, 0).tex(cx + maxx, cy).endVertex();
tessellator.getBuffer().pos(0, 0, 1).tex(cx, cy).endVertex();
//TOP
tessellator.getBuffer().pos(1, 1, 0).tex(cx, cy + maxy).endVertex();
tessellator.getBuffer().pos(0, 1, 0).tex(cx + maxx, cy + maxy).endVertex();
tessellator.getBuffer().pos(0, 1, 1).tex(cx + maxx, cy).endVertex();
tessellator.getBuffer().pos(1, 1, 1).tex(cx, cy).endVertex();
//DOWN
tessellator.getBuffer().pos(1, 0, 1).tex(cx, cy + maxy).endVertex();
tessellator.getBuffer().pos(0, 0, 1).tex(cx + maxx, cy + maxy).endVertex();
tessellator.getBuffer().pos(0, 0, 0).tex(cx + maxx, cy).endVertex();
tessellator.getBuffer().pos(1, 0, 0).tex(cx, cy).endVertex();
tessellator.draw();
if(!te.light.get(i)) {
GlStateManager.popAttrib();
GlStateManager.disableLighting();
GL11.glDisable(GL11.GL_LIGHTING);
Minecraft.getMinecraft().entityRenderer.disableLightmap();
}
GlStateManager.disableCull();
GL11.glPopMatrix();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment