1
0
Fork 0
tcr/client/src/main/java/client/renderer/tileentity/SignRenderer.java
2025-08-30 22:33:55 +02:00

92 lines
2.6 KiB
Java
Executable file

package client.renderer.tileentity;
import org.lwjgl.opengl.GL46;
import client.renderer.Drawing;
import client.renderer.GlState;
import common.block.tech.BlockStandingSign;
import common.block.tech.BlockWallSign;
import common.tileentity.TileEntitySign;
import common.world.State;
public class SignRenderer extends ElementRenderer<TileEntitySign>
{
public void renderElements(TileEntitySign te, double x, double y, double z, float partialTicks)
{
GL46.glPushMatrix();
float f = 0.6666667F;
State state = te.getState();
if (state.getBlock() instanceof BlockStandingSign)
{
GL46.glTranslatef((float)x + 0.5F, (float)y + 0.75F * f, (float)z + 0.5F);
int r = state.getValue(BlockStandingSign.FACING).getIndex();
float f1 = 0.0F;
if (r == 2)
{
f1 = 180.0F;
}
if (r == 4)
{
f1 = 90.0F;
}
if (r == 5)
{
f1 = -90.0F;
}
GL46.glRotatef(-f1, 0.0F, 1.0F, 0.0F);
GL46.glTranslatef(0.0F, f * -0.0625f * 2.0f, 0.0F);
}
else
{
int k = state.getBlock() instanceof BlockWallSign ? state.getValue(BlockWallSign.FACING).getIndex() : 0;
float f2 = 0.0F;
if (k == 2)
{
f2 = 180.0F;
}
if (k == 4)
{
f2 = 90.0F;
}
if (k == 5)
{
f2 = -90.0F;
}
GL46.glTranslatef((float)x + 0.5F, (float)y + 0.75F * f, (float)z + 0.5F);
GL46.glRotatef(-f2, 0.0F, 1.0F, 0.0F);
GL46.glTranslatef(0.0F, -0.3125F - f * 0.0625f * 0.5f, -0.4375F);
}
GlState.enableRescaleNormal();
float f3 = 0.015625F * f;
GL46.glTranslatef(0.0F, 0.5F * f, 0.1F * f);
GL46.glScalef(f3, -f3, f3);
GL46.glNormal3f(0.0F, 0.0F, -1.0F * f3);
GlState.depthMask(false);
for (int j = 0; j < te.text.length; ++j)
{
if (te.text[j] != null && !te.text[j].isEmpty())
{
String s = te.text[j].length() > 50 ? te.text[j].substring(0, 50) : te.text[j];
GL46.glPushMatrix();
GL46.glScalef(0.75f, 0.75f, 0.75f);
Drawing.drawTextCenteredN(s, 0, j * (18 - 3) - 30, 0xff000000);
GL46.glPopMatrix();
}
}
GlState.depthMask(true);
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
GL46.glPopMatrix();
}
}