fix lighting

This commit is contained in:
Sen 2025-07-17 17:28:30 +02:00
parent 2ea8656390
commit 3a9ec2ab32
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
14 changed files with 169 additions and 399 deletions

View file

@ -754,9 +754,9 @@ public class EntityRenderer {
for (int n = 0; n < 256; ++n)
{
float rsky = World.BRIGHTNESS[0][n / 16];
float rsky = World.BRIGHTNESS[n / 16];
float rblock = World.BRIGHTNESS[n % 16];
float sky = rsky * msun;
float rblock = World.BRIGHTNESS[0][n % 16];
float block = rblock * (this.torchFlickerX * 0.1F + 1.5F);
float sred = Math.max(sky * (sun * 0.65F + 0.35F), brightness);

View file

@ -647,11 +647,6 @@ public class RenderGlobal
break;
}
}
if (!flag2 && entity2 instanceof EntityBox)
{
this.gm.getRenderManager().renderFloatingBox(entity2, partialTicks);
}
}
}
}

View file

@ -2,55 +2,30 @@ package client.renderer.entity;
import org.lwjgl.opengl.GL11;
import client.Client;
import client.renderer.DefaultVertexFormats;
import client.renderer.Drawing;
import client.renderer.Frustum;
import client.renderer.GlState;
import client.renderer.RenderBuffer;
import client.renderer.Tessellator;
import client.renderer.texture.TextureAtlasSprite;
import client.renderer.texture.TextureMap;
import common.block.Block;
import common.entity.Entity;
import common.util.BlockPos;
import common.util.BoundingBox;
import common.world.World;
public abstract class Render<T extends Entity>
{
// public static boolean drawNames = true;
// private static final String shadowTextures = "textures/world/shadow.png";
protected final RenderManager renderManager;
// protected float shadowSize;
//
// /**
// * Determines the darkness of the object's shadow. Higher value makes a darker shadow.
// */
// protected float shadowOpaque = 1.0F;
protected final RenderManager manager;
protected Render(RenderManager renderManager)
protected Render(RenderManager manager)
{
this.renderManager = renderManager;
this.manager = manager;
}
public boolean shouldRender(T livingEntity, double camX, double camY, double camZ)
public boolean shouldRender(T entity, double camX, double camY, double camZ)
{
BoundingBox axisalignedbb = livingEntity.getEntityBoundingBox();
if (axisalignedbb.hasNaN() || axisalignedbb.getAverageEdgeLength() == 0.0D)
{
axisalignedbb = new BoundingBox(livingEntity.posX - 2.0D, livingEntity.posY - 2.0D, livingEntity.posZ - 2.0D, livingEntity.posX + 2.0D, livingEntity.posY + 2.0D, livingEntity.posZ + 2.0D);
}
return livingEntity.isInRangeToRender3d(camX, camY, camZ) && (livingEntity.noFrustumCheck || Frustum.isInFrustum(axisalignedbb));
BoundingBox bb = entity.getEntityBoundingBox();
if (bb.hasNaN() || bb.getAverageEdgeLength() == 0.0D)
bb = new BoundingBox(entity.posX - 2.0D, entity.posY - 2.0D, entity.posZ - 2.0D, entity.posX + 2.0D, entity.posY + 2.0D, entity.posZ + 2.0D);
return entity.isInRangeToRender3d(camX, camY, camZ) && (entity.noFrustumCheck || Frustum.isInFrustum(bb));
}
/**
* Renders the desired {@code T} type Entity.
*/
public void doRender(T entity, double x, double y, double z, float partialTicks)
public void doRender(T entity, double x, double y, double z, float partial)
{
this.renderName(entity, x, y, z);
}
@ -59,320 +34,27 @@ public abstract class Render<T extends Entity>
{
String name = entity.getDisplayName();
if(name != null && !name.isEmpty())
this.renderLivingLabel(entity, name, x, y, z, 64);
this.manager.renderLabel(entity, name, x, y, z, 64);
}
// protected boolean canRenderName(T entity)
// {
// return entity.hasCustomName();
// }
/**
* Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
*/
protected abstract String getEntityTexture(T entity);
public boolean bindEntityTexture(T entity)
public final boolean bindEntityTexture(T entity)
{
String resourcelocation = this.getEntityTexture(entity);
if (resourcelocation == null)
{
String tex = this.getEntityTexture(entity);
if(tex == null)
return false;
}
else
{
this.bindTexture(resourcelocation);
return true;
}
this.bindTexture(tex);
return true;
}
public void bindTexture(String location)
public final void bindTexture(String tex)
{
this.renderManager.renderEngine.bindTexture(location);
this.manager.renderEngine.bindTexture(tex);
}
/**
* Renders fire on top of the entity. Args: entity, x, y, z, partialTickTime
*/
private void renderEntityOnFire(Entity entity, double x, double y, double z, float partialTicks)
public final RenderManager getRenderManager()
{
GlState.disableLighting();
TextureMap texturemap = Client.CLIENT.getTextureMapBlocks();
TextureAtlasSprite textureatlassprite = texturemap.getAtlasSprite("blocks/fire_layer_0");
TextureAtlasSprite textureatlassprite1 = texturemap.getAtlasSprite("blocks/fire_layer_1");
GL11.glPushMatrix();
GL11.glTranslatef((float)x, (float)y, (float)z);
float f = entity.width * 1.4F;
GL11.glScalef(f, f, f);
// Tessellator tessellator = Tessellator.getInstance();
RenderBuffer worldrenderer = Tessellator.getBuffer();
float f1 = 0.5F;
float f2 = 0.0F;
float f3 = entity.height / f;
float f4 = (float)(entity.posY - entity.getEntityBoundingBox().minY);
GL11.glRotatef(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
GL11.glTranslatef(0.0F, 0.0F, -0.3F + (float)((int)f3) * 0.02F);
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
float f5 = 0.0F;
int i = 0;
worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
while (f3 > 0.0F)
{
TextureAtlasSprite textureatlassprite2 = i % 2 == 0 ? textureatlassprite : textureatlassprite1;
this.bindTexture(TextureMap.BLOCKS);
float f6 = textureatlassprite2.getMinU();
float f7 = textureatlassprite2.getMinV();
float f8 = textureatlassprite2.getMaxU();
float f9 = textureatlassprite2.getMaxV();
if (i / 2 % 2 == 0)
{
float f10 = f8;
f8 = f6;
f6 = f10;
}
worldrenderer.pos((double)(f1 - f2), (double)(0.0F - f4), (double)f5).tex((double)f8, (double)f9).endVertex();
worldrenderer.pos((double)(-f1 - f2), (double)(0.0F - f4), (double)f5).tex((double)f6, (double)f9).endVertex();
worldrenderer.pos((double)(-f1 - f2), (double)(1.4F - f4), (double)f5).tex((double)f6, (double)f7).endVertex();
worldrenderer.pos((double)(f1 - f2), (double)(1.4F - f4), (double)f5).tex((double)f8, (double)f7).endVertex();
f3 -= 0.45F;
f4 -= 0.45F;
f1 *= 0.9F;
f5 += 0.03F;
++i;
}
Tessellator.draw();
GL11.glPopMatrix();
GlState.enableLighting();
}
// /**
// * Renders the entity shadows at the position, shadow alpha and partialTickTime. Args: entity, x, y, z, shadowAlpha,
// * partialTickTime
// */
// private void renderShadow(Entity entityIn, double x, double y, double z, float shadowAlpha, float partialTicks)
// {
// GlState.enableBlend();
// GlState.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
// this.renderManager.renderEngine.bindTexture(shadowTextures);
// World world = this.getWorldFromRenderManager();
// GlState.depthMask(false);
// float f = this.shadowSize;
//
// if (entityIn instanceof EntityLiving)
// {
// EntityLiving entityliving = (EntityLiving)entityIn;
// f *= entityliving.getShadowSize();
//
// if (entityliving.isChild())
// {
// f *= 0.5F;
// }
// }
//
// double d5 = entityIn.lastTickPosX + (entityIn.posX - entityIn.lastTickPosX) * (double)partialTicks;
// double d0 = entityIn.lastTickPosY + (entityIn.posY - entityIn.lastTickPosY) * (double)partialTicks;
// double d1 = entityIn.lastTickPosZ + (entityIn.posZ - entityIn.lastTickPosZ) * (double)partialTicks;
// int i = MathHelper.floor_double(d5 - (double)f);
// int j = MathHelper.floor_double(d5 + (double)f);
// int k = MathHelper.floor_double(d0 - (double)f);
// int l = MathHelper.floor_double(d0);
// int i1 = MathHelper.floor_double(d1 - (double)f);
// int j1 = MathHelper.floor_double(d1 + (double)f);
// double d2 = x - d5;
// double d3 = y - d0;
// double d4 = z - d1;
//// Tessellator tessellator = Tessellator.getInstance();
// RenderBuffer worldrenderer = Tessellator.getBuffer();
// worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
//
// for (BlockPos blockpos : BlockPos.getAllInBoxMutable(new BlockPos(i, k, i1), new BlockPos(j, l, j1)))
// {
// Block block = world.getBlockState(blockpos.down()).getBlock();
//
// if (block.getRenderType() != -1 && world.getLightFromNeighbors(blockpos) > 3)
// {
// this.renderShadowBlock(block, x, y, z, blockpos, shadowAlpha, f, d2, d3, d4);
// }
// }
//
// Tessellator.draw();
// GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
// GlState.disableBlend();
// GlState.depthMask(true);
// }
/**
* Returns the render manager's world object
*/
private World getWorldFromRenderManager()
{
return this.renderManager.worldObj;
}
private void renderShadowBlock(Block blockIn, double p_180549_2_, double p_180549_4_, double p_180549_6_, BlockPos pos, float p_180549_9_, float p_180549_10_, double p_180549_11_, double p_180549_13_, double p_180549_15_)
{
if (blockIn.isFullCube())
{
// Tessellator tessellator = Tessellator.getInstance();
RenderBuffer worldrenderer = Tessellator.getBuffer();
double d0 = ((double)p_180549_9_ - (p_180549_4_ - ((double)pos.getY() + p_180549_13_)) / 2.0D) * 0.5D * (double)this.getWorldFromRenderManager().getLightBrightness(pos);
if (d0 >= 0.0D)
{
if (d0 > 1.0D)
{
d0 = 1.0D;
}
double d1 = (double)pos.getX() + blockIn.getBlockBoundsMinX() + p_180549_11_;
double d2 = (double)pos.getX() + blockIn.getBlockBoundsMaxX() + p_180549_11_;
double d3 = (double)pos.getY() + blockIn.getBlockBoundsMinY() + p_180549_13_ + 0.015625D;
double d4 = (double)pos.getZ() + blockIn.getBlockBoundsMinZ() + p_180549_15_;
double d5 = (double)pos.getZ() + blockIn.getBlockBoundsMaxZ() + p_180549_15_;
float f = (float)((p_180549_2_ - d1) / 2.0D / (double)p_180549_10_ + 0.5D);
float f1 = (float)((p_180549_2_ - d2) / 2.0D / (double)p_180549_10_ + 0.5D);
float f2 = (float)((p_180549_6_ - d4) / 2.0D / (double)p_180549_10_ + 0.5D);
float f3 = (float)((p_180549_6_ - d5) / 2.0D / (double)p_180549_10_ + 0.5D);
worldrenderer.pos(d1, d3, d4).tex((double)f, (double)f2).color(1.0F, 1.0F, 1.0F, (float)d0).endVertex();
worldrenderer.pos(d1, d3, d5).tex((double)f, (double)f3).color(1.0F, 1.0F, 1.0F, (float)d0).endVertex();
worldrenderer.pos(d2, d3, d5).tex((double)f1, (double)f3).color(1.0F, 1.0F, 1.0F, (float)d0).endVertex();
worldrenderer.pos(d2, d3, d4).tex((double)f1, (double)f2).color(1.0F, 1.0F, 1.0F, (float)d0).endVertex();
}
}
}
/**
* Renders a white box with the bounds of the AABB translated by the offset. Args: aabb, x, y, z
*/
public static void renderOffsetAABB(BoundingBox boundingBox, double x, double y, double z)
{
GlState.disableTexture2D();
// Tessellator tessellator = Tessellator.getInstance();
RenderBuffer worldrenderer = Tessellator.getBuffer();
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
worldrenderer.setTranslation(x, y, z);
worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_NORMAL);
worldrenderer.pos(boundingBox.minX, boundingBox.maxY, boundingBox.minZ).normal(0.0F, 0.0F, -1.0F).endVertex();
worldrenderer.pos(boundingBox.maxX, boundingBox.maxY, boundingBox.minZ).normal(0.0F, 0.0F, -1.0F).endVertex();
worldrenderer.pos(boundingBox.maxX, boundingBox.minY, boundingBox.minZ).normal(0.0F, 0.0F, -1.0F).endVertex();
worldrenderer.pos(boundingBox.minX, boundingBox.minY, boundingBox.minZ).normal(0.0F, 0.0F, -1.0F).endVertex();
worldrenderer.pos(boundingBox.minX, boundingBox.minY, boundingBox.maxZ).normal(0.0F, 0.0F, 1.0F).endVertex();
worldrenderer.pos(boundingBox.maxX, boundingBox.minY, boundingBox.maxZ).normal(0.0F, 0.0F, 1.0F).endVertex();
worldrenderer.pos(boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ).normal(0.0F, 0.0F, 1.0F).endVertex();
worldrenderer.pos(boundingBox.minX, boundingBox.maxY, boundingBox.maxZ).normal(0.0F, 0.0F, 1.0F).endVertex();
worldrenderer.pos(boundingBox.minX, boundingBox.minY, boundingBox.minZ).normal(0.0F, -1.0F, 0.0F).endVertex();
worldrenderer.pos(boundingBox.maxX, boundingBox.minY, boundingBox.minZ).normal(0.0F, -1.0F, 0.0F).endVertex();
worldrenderer.pos(boundingBox.maxX, boundingBox.minY, boundingBox.maxZ).normal(0.0F, -1.0F, 0.0F).endVertex();
worldrenderer.pos(boundingBox.minX, boundingBox.minY, boundingBox.maxZ).normal(0.0F, -1.0F, 0.0F).endVertex();
worldrenderer.pos(boundingBox.minX, boundingBox.maxY, boundingBox.maxZ).normal(0.0F, 1.0F, 0.0F).endVertex();
worldrenderer.pos(boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ).normal(0.0F, 1.0F, 0.0F).endVertex();
worldrenderer.pos(boundingBox.maxX, boundingBox.maxY, boundingBox.minZ).normal(0.0F, 1.0F, 0.0F).endVertex();
worldrenderer.pos(boundingBox.minX, boundingBox.maxY, boundingBox.minZ).normal(0.0F, 1.0F, 0.0F).endVertex();
worldrenderer.pos(boundingBox.minX, boundingBox.minY, boundingBox.maxZ).normal(-1.0F, 0.0F, 0.0F).endVertex();
worldrenderer.pos(boundingBox.minX, boundingBox.maxY, boundingBox.maxZ).normal(-1.0F, 0.0F, 0.0F).endVertex();
worldrenderer.pos(boundingBox.minX, boundingBox.maxY, boundingBox.minZ).normal(-1.0F, 0.0F, 0.0F).endVertex();
worldrenderer.pos(boundingBox.minX, boundingBox.minY, boundingBox.minZ).normal(-1.0F, 0.0F, 0.0F).endVertex();
worldrenderer.pos(boundingBox.maxX, boundingBox.minY, boundingBox.minZ).normal(1.0F, 0.0F, 0.0F).endVertex();
worldrenderer.pos(boundingBox.maxX, boundingBox.maxY, boundingBox.minZ).normal(1.0F, 0.0F, 0.0F).endVertex();
worldrenderer.pos(boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ).normal(1.0F, 0.0F, 0.0F).endVertex();
worldrenderer.pos(boundingBox.maxX, boundingBox.minY, boundingBox.maxZ).normal(1.0F, 0.0F, 0.0F).endVertex();
Tessellator.draw();
worldrenderer.setTranslation(0.0D, 0.0D, 0.0D);
GlState.enableTexture2D();
}
public void doRenderShadowAndFire(Entity entityIn, double x, double y, double z, float partialTicks)
{
if (this.renderManager.gm != null)
{
// if (this.renderManager.options.entityShadows && this.shadowSize > 0.0F && !entityIn.isInvisible() && this.renderManager.isRenderShadow())
// {
// double d0 = this.renderManager.getDistanceToCamera(entityIn.posX, entityIn.posY, entityIn.posZ);
// float f = (float)((1.0D - d0 / 256.0D) * (double)this.shadowOpaque);
//
// if (f > 0.0F)
// {
// this.renderShadow(entityIn, x, y, z, f, partialTicks);
// }
// }
if (entityIn.canRenderOnFire()) // && (!(entityIn.isPlayer()) || !((EntityNPC)entityIn).isSpectator()))
{
this.renderEntityOnFire(entityIn, x, y, z, partialTicks);
}
}
}
protected void renderLivingLabel(T entityIn, String str, double x, double y, double z, int maxDistance) {
double d0 = entityIn.getDistanceSqToEntity(this.renderManager.livingPlayer);
if (d0 <= (double)(maxDistance * maxDistance) && this.renderManager.gm.canRenderHud()) {
// WCF.glPushMatrix();
// WCF.glTranslatef((float)x, (float)y + entityIn.height + 0.5f, (float)z);
// float f = 1.0f / 64.0f;
// WCF.glScalef(f, f, f);
// int w, h;
// Vec2i size = Drawing.txt_size(0, 0, 0, 0, 65536, 65536, Font.DEFAULT, str);
// int tx = - size.xpos / 2;
// int ty = - size.ypos;
// Drawing.txt_draw(tx, ty, tx, ty, tx + 440, ty + 260, 0xffffffff, 0x3f000000, Font.DEFAULT, str);
//// this.renderManager.addOverlay(x, y + (double)entityIn.height + 0.5, z, str);
// WCF.glPopMatrix();
// FontRenderer fontrenderer = this.getFontRendererFromRenderManager();
float f = 1.0f; // 1.6F;
float f1 = 0.016666668F * f;
GL11.glPushMatrix();
GL11.glTranslatef((float)x + 0.0F, (float)y + entityIn.height + 0.5F, (float)z);
GL11.glNormal3f(0.0F, 1.0F, 0.0F);
GL11.glRotatef(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
GL11.glScalef(-f1, -f1, f1);
GlState.disableLighting();
GlState.depthMask(false);
// GlState.disableDepth();
GlState.enableBlend();
GlState.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
// Tessellator tessellator = Tessellator.getInstance();
RenderBuffer worldrenderer = Tessellator.getBuffer();
// int i = 0;
// if (str.equals("deadmau5"))
// {
// i = -10;
// }
// Vec2i size = Drawing.txt_size(0, 0, 0, 0, 65536, 65536, str);
// int j = size.xpos / 2;
// GlState.disableTexture2D();
// worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
// worldrenderer.pos((double)(-j - 1), (double)(-1 + i), 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
// worldrenderer.pos((double)(-j - 1), (double)(8 + i), 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
// worldrenderer.pos((double)(j + 1), (double)(8 + i), 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
// worldrenderer.pos((double)(j + 1), (double)(-1 + i), 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
// Tessellator.draw();
// GlState.enableTexture2D();
// int tx = -size.xpos / 2; // j;
// int ty = 0; // i;
// Drawing.txt_draw(tx, ty, tx, ty, tx + 440, ty + 260, /* 0xffffffff */ 553648127, 0x3f000000, Font.DEFAULT, str);
// FontRenderer.drawString(str, -FontRenderer.getStringWidth(str) / 2, i, 553648127);
// GlState.enableDepth();
GlState.depthMask(true);
Drawing.drawTextboxCentered(str, 0, 0, 0x3f000000);
// FontRenderer.drawString(str, -FontRenderer.getStringWidth(str) / 2, i, -1);
GlState.enableLighting();
GlState.disableBlend();
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glPopMatrix();
}
}
public RenderManager getRenderManager()
{
return this.renderManager;
return this.manager;
}
}

View file

@ -2,19 +2,57 @@ package client.renderer.entity;
import org.lwjgl.opengl.GL11;
import client.renderer.DefaultVertexFormats;
import client.renderer.GlState;
import client.renderer.RenderBuffer;
import client.renderer.Tessellator;
import common.entity.Entity;
import common.util.BoundingBox;
public class RenderEntity extends Render<Entity>
{
public static void renderOffsetAABB(BoundingBox bb, double x, double y, double z)
{
GlState.disableTexture2D();
RenderBuffer rb = Tessellator.getBuffer();
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
rb.setTranslation(x, y, z);
rb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_NORMAL);
rb.pos(bb.minX, bb.maxY, bb.minZ).normal(0.0F, 0.0F, -1.0F).endVertex();
rb.pos(bb.maxX, bb.maxY, bb.minZ).normal(0.0F, 0.0F, -1.0F).endVertex();
rb.pos(bb.maxX, bb.minY, bb.minZ).normal(0.0F, 0.0F, -1.0F).endVertex();
rb.pos(bb.minX, bb.minY, bb.minZ).normal(0.0F, 0.0F, -1.0F).endVertex();
rb.pos(bb.minX, bb.minY, bb.maxZ).normal(0.0F, 0.0F, 1.0F).endVertex();
rb.pos(bb.maxX, bb.minY, bb.maxZ).normal(0.0F, 0.0F, 1.0F).endVertex();
rb.pos(bb.maxX, bb.maxY, bb.maxZ).normal(0.0F, 0.0F, 1.0F).endVertex();
rb.pos(bb.minX, bb.maxY, bb.maxZ).normal(0.0F, 0.0F, 1.0F).endVertex();
rb.pos(bb.minX, bb.minY, bb.minZ).normal(0.0F, -1.0F, 0.0F).endVertex();
rb.pos(bb.maxX, bb.minY, bb.minZ).normal(0.0F, -1.0F, 0.0F).endVertex();
rb.pos(bb.maxX, bb.minY, bb.maxZ).normal(0.0F, -1.0F, 0.0F).endVertex();
rb.pos(bb.minX, bb.minY, bb.maxZ).normal(0.0F, -1.0F, 0.0F).endVertex();
rb.pos(bb.minX, bb.maxY, bb.maxZ).normal(0.0F, 1.0F, 0.0F).endVertex();
rb.pos(bb.maxX, bb.maxY, bb.maxZ).normal(0.0F, 1.0F, 0.0F).endVertex();
rb.pos(bb.maxX, bb.maxY, bb.minZ).normal(0.0F, 1.0F, 0.0F).endVertex();
rb.pos(bb.minX, bb.maxY, bb.minZ).normal(0.0F, 1.0F, 0.0F).endVertex();
rb.pos(bb.minX, bb.minY, bb.maxZ).normal(-1.0F, 0.0F, 0.0F).endVertex();
rb.pos(bb.minX, bb.maxY, bb.maxZ).normal(-1.0F, 0.0F, 0.0F).endVertex();
rb.pos(bb.minX, bb.maxY, bb.minZ).normal(-1.0F, 0.0F, 0.0F).endVertex();
rb.pos(bb.minX, bb.minY, bb.minZ).normal(-1.0F, 0.0F, 0.0F).endVertex();
rb.pos(bb.maxX, bb.minY, bb.minZ).normal(1.0F, 0.0F, 0.0F).endVertex();
rb.pos(bb.maxX, bb.maxY, bb.minZ).normal(1.0F, 0.0F, 0.0F).endVertex();
rb.pos(bb.maxX, bb.maxY, bb.maxZ).normal(1.0F, 0.0F, 0.0F).endVertex();
rb.pos(bb.maxX, bb.minY, bb.maxZ).normal(1.0F, 0.0F, 0.0F).endVertex();
Tessellator.draw();
rb.setTranslation(0.0D, 0.0D, 0.0D);
GlState.enableTexture2D();
}
public RenderEntity(RenderManager renderManagerIn)
{
super(renderManagerIn);
}
/**
* Renders the desired {@code T} type Entity.
*/
public void doRender(Entity entity, double x, double y, double z, float partialTicks)
{
GL11.glPushMatrix();
@ -23,9 +61,6 @@ public class RenderEntity extends Render<Entity>
super.doRender(entity, x, y, z, partialTicks);
}
/**
* Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
*/
protected String getEntityTexture(Entity entity)
{
return null;

View file

@ -43,7 +43,7 @@ public class RenderEntityItem extends Render<EntityItem>
float f2 = p_177077_9_.getTransforms().get(Transforms.Camera.GROUND).scale();
GL11.glTranslatef((float)p_177077_2_, (float)p_177077_4_ + f1 + 0.25F * f2, (float)p_177077_6_);
if (flag || this.renderManager.gm != null)
if (flag || this.manager.gm != null)
{
float f3 = (((float)itemIn.getAge() + p_177077_8_) / 20.0F + itemIn.hoverStart) * (180F / (float)Math.PI);
GL11.glRotatef(f3, 0.0F, 1.0F, 0.0F);

View file

@ -43,8 +43,8 @@ public class RenderFireball extends Render<EntityProjectile>
float f4 = 1.0F;
float f5 = 0.5F;
float f6 = 0.25F;
GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(180.0F - this.manager.playerViewY, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(-this.manager.playerViewX, 1.0F, 0.0F, 0.0F);
worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_NORMAL);
worldrenderer.pos(-0.5D, -0.25D, 0.0D).tex((double)f, (double)f3).normal(0.0F, 1.0F, 0.0F).endVertex();
worldrenderer.pos(0.5D, -0.25D, 0.0D).tex((double)f1, (double)f3).normal(0.0F, 1.0F, 0.0F).endVertex();

View file

@ -41,8 +41,8 @@ public class RenderFish extends Render<EntityHook>
float f4 = 1.0F;
float f5 = 0.5F;
float f6 = 0.5F;
GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(180.0F - this.manager.playerViewY, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(-this.manager.playerViewX, 1.0F, 0.0F, 0.0F);
worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_NORMAL);
worldrenderer.pos(-0.5D, -0.5D, 0.0D).tex(0.0D, 0.25D).normal(0.0F, 1.0F, 0.0F).endVertex();
worldrenderer.pos(0.5D, -0.5D, 0.0D).tex(0.25D, 0.25D).normal(0.0F, 1.0F, 0.0F).endVertex();
@ -66,7 +66,7 @@ public class RenderFish extends Render<EntityHook>
double d2 = entity.angler.prevZ + (entity.angler.posZ - entity.angler.prevZ) * (double)partialTicks + vec3.zCoord;
double d3 = (double)entity.angler.getEyeHeight();
if (this.renderManager.gm != null && this.renderManager.gm.thirdPersonView > 0 || entity.angler != Client.CLIENT.player)
if (this.manager.gm != null && this.manager.gm.thirdPersonView > 0 || entity.angler != Client.CLIENT.player)
{
float f9 = (entity.angler.prevYawOffset + (entity.angler.yawOffset - entity.angler.prevYawOffset) * partialTicks) * (float)Math.PI / 180.0F;
double d4 = (double)ExtMath.sin(f9);

View file

@ -69,12 +69,12 @@ public class RenderHumanoid extends RenderNpc
public void doRender(EntityNPC entity, double x, double y, double z, float partialTicks)
{
if (entity != this.renderManager.gm.player || this.renderManager.livingPlayer == entity)
if (entity != this.manager.gm.player || this.manager.livingPlayer == entity)
{
// if(entity.isBoss())
// BossStatus.setBossStatus(entity);
double d0 = y;
if(/* this.canSneak() && */ entity.isSneakingVisually() && entity != this.renderManager.gm.player)
if(/* this.canSneak() && */ entity.isSneakingVisually() && entity != this.manager.gm.player)
d0 = y - 0.125D;
this.setModelVisibilities(entity);
super.doRender(entity, x, d0, z, partialTicks);

View file

@ -28,8 +28,8 @@ public class RenderItemEntity<T extends Entity> extends Render<T>
GL11.glTranslatef((float)x, (float)y, (float)z);
GlState.enableRescaleNormal();
GL11.glScalef(0.5F, 0.5F, 0.5F);
GL11.glRotatef(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(-this.manager.playerViewY, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(this.manager.playerViewX, 1.0F, 0.0F, 0.0F);
this.bindTexture(TextureMap.BLOCKS);
this.itemRenderer.renderItem(this.getStack(entity), Transforms.Camera.GROUND);
GlState.disableRescaleNormal();

View file

@ -38,7 +38,7 @@ public abstract class RenderLiving<T extends EntityLiving> extends RendererLivin
public void doRender(T entity, double x, double y, double z, float partial) {
if(entity.isBoss())
this.renderManager.gm.setBossStatus(entity);
this.manager.gm.setBossStatus(entity);
super.doRender(entity, x, y, z, partial);
this.renderLeash(entity, x, y, z, partial);
}

View file

@ -8,11 +8,14 @@ import org.lwjgl.opengl.GL13;
import client.Client;
import client.init.RenderRegistry;
import client.renderer.DefaultVertexFormats;
import client.renderer.Drawing;
import client.renderer.GlState;
import client.renderer.RenderBuffer;
import client.renderer.RenderGlobal;
import client.renderer.Tessellator;
import client.renderer.texture.TextureAtlasSprite;
import client.renderer.texture.TextureManager;
import client.renderer.texture.TextureMap;
import common.collect.Maps;
import common.entity.Entity;
import common.entity.types.EntityLiving;
@ -239,24 +242,6 @@ public class RenderManager
return this.renderEntity(entity, d0 - this.renderPosX, d1 - this.renderPosY, d2 - this.renderPosZ, partialTicks);
}
public void renderFloatingBox(Entity entityIn, float partialTicks)
{
double d0 = entityIn.lastTickPosX + (entityIn.posX - entityIn.lastTickPosX) * (double)partialTicks;
double d1 = entityIn.lastTickPosY + (entityIn.posY - entityIn.lastTickPosY) * (double)partialTicks;
double d2 = entityIn.lastTickPosZ + (entityIn.posZ - entityIn.lastTickPosZ) * (double)partialTicks;
Render<Entity> render = this.<Entity>getEntityRenderObject(entityIn);
if (render != null && this.renderEngine != null)
{
int i = entityIn.getBrightnessForRender(partialTicks);
int j = i % 65536;
int k = i / 65536;
GL13.glMultiTexCoord2f(GL13.GL_TEXTURE1, (float)j / 1.0F, (float)k / 1.0F);
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
render.renderName(entityIn, d0 - this.renderPosX, d1 - this.renderPosY, d2 - this.renderPosZ);
}
}
public boolean renderEntity(Entity entity, double x, double y, double z, float partialTicks)
{
Render<Entity> render = this.<Entity>getEntityRenderObject(entity);
@ -270,9 +255,9 @@ public class RenderManager
render.doRender(entity, x, y, z, partialTicks);
if (!this.renderOutlines)
if (!this.renderOutlines && this.gm != null && entity.canRenderOnFire())
{
render.doRenderShadowAndFire(entity, x, y, z, partialTicks);
this.renderEntityFire(entity, x, y, z);
}
if (this.debugBoundingBox) // && !entity.isInvisible()) // && !hideDebugBox)
@ -287,6 +272,85 @@ public class RenderManager
return true;
}
public void renderLabel(Entity entity, String str, double x, double y, double z, int maxDistance) {
if(this.gm == null)
return;
double dist = entity.getDistanceSqToEntity(this.livingPlayer);
if(dist > (double)(maxDistance * maxDistance) || !this.gm.canRenderHud())
return;
float scale = 0.016666668F;
GL11.glPushMatrix();
GL11.glTranslatef((float)x + 0.0F, (float)y + entity.height + 0.5F, (float)z);
GL11.glNormal3f(0.0F, 1.0F, 0.0F);
GL11.glRotatef(-this.playerViewY, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(this.playerViewX, 1.0F, 0.0F, 0.0F);
GL11.glScalef(-scale, -scale, scale);
GlState.disableLighting();
GlState.depthMask(false);
GlState.enableBlend();
GlState.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
GlState.depthMask(true);
Drawing.drawTextboxCentered(str, 0, 0, 0x3f000000);
GlState.enableLighting();
GlState.disableBlend();
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glPopMatrix();
}
private void renderEntityFire(Entity entity, double x, double y, double z)
{
GlState.disableLighting();
TextureMap map = this.gm.getTextureMapBlocks();
TextureAtlasSprite layer0 = map.getAtlasSprite("blocks/fire_layer_0");
TextureAtlasSprite layer1 = map.getAtlasSprite("blocks/fire_layer_1");
GL11.glPushMatrix();
GL11.glTranslatef((float)x, (float)y, (float)z);
float scale = entity.width * 1.4F;
GL11.glScalef(scale, scale, scale);
RenderBuffer rb = Tessellator.getBuffer();
float f1 = 0.5F;
float f2 = 0.0F;
float f3 = entity.height / scale;
float f4 = (float)(entity.posY - entity.getEntityBoundingBox().minY);
GL11.glRotatef(-this.playerViewY, 0.0F, 1.0F, 0.0F);
GL11.glTranslatef(0.0F, 0.0F, -0.3F + (float)((int)f3) * 0.02F);
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
float f5 = 0.0F;
int i = 0;
rb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
while (f3 > 0.0F)
{
TextureAtlasSprite layer = i % 2 == 0 ? layer0 : layer1;
this.renderEngine.bindTexture(TextureMap.BLOCKS);
float f6 = layer.getMinU();
float f7 = layer.getMinV();
float f8 = layer.getMaxU();
float f9 = layer.getMaxV();
if (i / 2 % 2 == 0)
{
float f10 = f8;
f8 = f6;
f6 = f10;
}
rb.pos((double)(f1 - f2), (double)(0.0F - f4), (double)f5).tex((double)f8, (double)f9).endVertex();
rb.pos((double)(-f1 - f2), (double)(0.0F - f4), (double)f5).tex((double)f6, (double)f9).endVertex();
rb.pos((double)(-f1 - f2), (double)(1.4F - f4), (double)f5).tex((double)f6, (double)f7).endVertex();
rb.pos((double)(f1 - f2), (double)(1.4F - f4), (double)f5).tex((double)f8, (double)f7).endVertex();
f3 -= 0.45F;
f4 -= 0.45F;
f1 *= 0.9F;
f5 += 0.03F;
++i;
}
Tessellator.draw();
GL11.glPopMatrix();
GlState.enableLighting();
}
private void renderDebugBoundingBox(Entity entityIn, double x, double y, double z, float partialTicks)
{

View file

@ -39,8 +39,8 @@ public class RenderXp extends Render<EntityXp> {
float n = (int)((ExtMath.sin(color + (float)Math.PI) + 1.0F) * 0.5F * 255.0F);
int r = (int)(n * (value / 10.0f));
int b = (int)(n * ((10 - value) / 10.0f));
GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(180.0F - this.manager.playerViewY, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(-this.manager.playerViewX, 1.0F, 0.0F, 0.0F);
float size = 0.25F;
GL11.glScalef(size, size, size);
RenderBuffer rb = Tessellator.getBuffer();
@ -64,7 +64,10 @@ public class RenderXp extends Render<EntityXp> {
return TEXTURE;
}
protected void renderLivingLabel(EntityXp entityIn, String str, double x, double y, double z, int maxDistance) {
super.renderLivingLabel(entityIn, str, x, y - 0.5, z, maxDistance);
}
protected void renderName(EntityXp entity, double x, double y, double z)
{
String name = entity.getDisplayName();
if(name != null && !name.isEmpty())
this.manager.renderLabel(entity, name, x, y - 0.5, z, 64);
}
}

View file

@ -502,9 +502,9 @@ public abstract class RendererLivingEntity<T extends EntityLiving> extends Rende
{
String name = entity.getDisplayName();
if(name != null && !name.isEmpty())
this.renderLivingLabel(entity, name, x, entity.isSneakingVisually() ? y - 0.25 : y, z, 64);
this.manager.renderLabel(entity, name, x, entity.isSneakingVisually() ? y - 0.25 : y, z, 64);
if(entity.isEntityAlive())
this.renderLivingLabel(entity, entity.formatStats(), x, (entity.isSneakingVisually() ? y - 0.25 : y) + 0.3, z, 32);
this.manager.renderLabel(entity, entity.formatStats(), x, (entity.isSneakingVisually() ? y - 0.25 : y) + 0.3, z, 32);
}
// protected boolean canRenderName(T entity)