minor light cleanup
This commit is contained in:
parent
aaad753263
commit
375a67d10f
23 changed files with 53 additions and 215 deletions
|
@ -39,6 +39,7 @@ import client.renderer.tileentity.SpecialRenderer;
|
|||
import client.world.ChunkClient;
|
||||
import common.block.Block;
|
||||
import common.block.Material;
|
||||
import common.block.artificial.BlockSlab;
|
||||
import common.block.liquid.BlockDynamicLiquid;
|
||||
import common.block.liquid.BlockLiquid;
|
||||
import common.block.liquid.BlockStaticLiquid;
|
||||
|
@ -3505,6 +3506,27 @@ public class Renderer {
|
|||
Tessellator.draw();
|
||||
}
|
||||
}
|
||||
|
||||
private static final int getLightmapValue(IWorldAccess world, BlockPos pos) {
|
||||
Block block = world.getState(pos).getBlock();
|
||||
int light = world.getCombinedLight(pos, block.getLight());
|
||||
if(light == 0 && block instanceof BlockSlab) {
|
||||
pos = pos.down();
|
||||
block = world.getState(pos).getBlock();
|
||||
return world.getCombinedLight(pos, block.getLight());
|
||||
}
|
||||
return light;
|
||||
}
|
||||
|
||||
private static final int getLightmapValueLiquid(IWorldAccess world, BlockPos pos) {
|
||||
int i = world.getCombinedLight(pos, 0);
|
||||
int j = world.getCombinedLight(pos.up(), 0);
|
||||
int k = i & 255;
|
||||
int l = j & 255;
|
||||
int i1 = i >> 16 & 255;
|
||||
int j1 = j >> 16 & 255;
|
||||
return (k > l ? k : l) | (i1 > j1 ? i1 : j1) << 16;
|
||||
}
|
||||
|
||||
public boolean renderModel(IWorldAccess blockAccessIn, IBakedModel modelIn, State blockStateIn, BlockPos blockPosIn, RenderBuffer worldRendererIn, boolean checkSides)
|
||||
{
|
||||
|
@ -3522,7 +3544,7 @@ public class Renderer {
|
|||
|
||||
if (!checkSides || blockIn.canRender(blockAccessIn, blockpos, enumfacing))
|
||||
{
|
||||
int i = blockIn.getLightmapValue(blockAccessIn, blockpos);
|
||||
int i = getLightmapValue(blockAccessIn, blockpos);
|
||||
this.renderModelStandardQuads(blockAccessIn, blockIn, blockPosIn, enumfacing, i, false, worldRendererIn, list, bitset);
|
||||
flag = true;
|
||||
}
|
||||
|
@ -3551,7 +3573,7 @@ public class Renderer {
|
|||
if (ownBrightness)
|
||||
{
|
||||
this.fillQuadBounds(blockIn, bakedquad.getVertexData(), bakedquad.getFace(), (float[])null, boundsFlags);
|
||||
brightnessIn = boundsFlags.get(0) ? blockIn.getLightmapValue(blockAccessIn, blockPosIn.offset(bakedquad.getFace())) : blockIn.getLightmapValue(blockAccessIn, blockPosIn);
|
||||
brightnessIn = boundsFlags.get(0) ? getLightmapValue(blockAccessIn, blockPosIn.offset(bakedquad.getFace())) : getLightmapValue(blockAccessIn, blockPosIn);
|
||||
}
|
||||
|
||||
worldRendererIn.addVertexData(bakedquad.getVertexData());
|
||||
|
@ -3713,7 +3735,7 @@ public class Renderer {
|
|||
f20 = textureatlassprite.getInterpolatedV((double)(8.0F + (-f22 - f21) * 16.0F));
|
||||
}
|
||||
|
||||
int k2 = blockliquid.getLightmapValue(blockAccess, blockPosIn);
|
||||
int k2 = getLightmapValueLiquid(blockAccess, blockPosIn);
|
||||
int l2 = k2 >> 16 & 65535;
|
||||
int i3 = k2 & 65535;
|
||||
float f24 = f4;
|
||||
|
@ -3739,7 +3761,7 @@ public class Renderer {
|
|||
float f36 = atextureatlassprite[0].getMaxU();
|
||||
float f37 = atextureatlassprite[0].getMinV();
|
||||
float f38 = atextureatlassprite[0].getMaxV();
|
||||
int l1 = blockliquid.getLightmapValue(blockAccess, blockPosIn.down());
|
||||
int l1 = getLightmapValueLiquid(blockAccess, blockPosIn.down());
|
||||
int i2 = l1 >> 16 & 65535;
|
||||
int j2 = l1 & 65535;
|
||||
worldRendererIn.pos(d0, d1, d2 + 1.0D).color(f3, f3, f3, 1.0F).tex((double)f35, (double)f38).lightmap(i2, j2).endVertex();
|
||||
|
@ -3829,7 +3851,7 @@ public class Renderer {
|
|||
float f28 = textureatlassprite1.getInterpolatedV((double)((1.0F - f39) * 16.0F * 0.5F));
|
||||
float f29 = textureatlassprite1.getInterpolatedV((double)((1.0F - f40) * 16.0F * 0.5F));
|
||||
float f30 = textureatlassprite1.getInterpolatedV(8.0D);
|
||||
int j = blockliquid.getLightmapValue(blockAccess, blockpos);
|
||||
int j = getLightmapValueLiquid(blockAccess, blockpos);
|
||||
int k = j >> 16 & 65535;
|
||||
int l = j & 65535;
|
||||
float f31 = i1 < 2 ? f5 : f6;
|
||||
|
|
|
@ -2,6 +2,7 @@ package client.renderer.entity;
|
|||
|
||||
import client.renderer.Frustum;
|
||||
import common.entity.Entity;
|
||||
import common.util.BlockPos;
|
||||
import common.util.BoundingBox;
|
||||
|
||||
public abstract class Render<T extends Entity>
|
||||
|
@ -53,4 +54,9 @@ public abstract class Render<T extends Entity>
|
|||
{
|
||||
return this.manager;
|
||||
}
|
||||
|
||||
protected static float getBrightness(Entity entity) {
|
||||
BlockPos pos = new BlockPos(entity.posX, entity.posY + (double)entity.getEyeHeight(), entity.posZ);
|
||||
return entity.worldObj.isBlockLoaded(pos) ? entity.worldObj.getLightBrightness(pos) : 0.0F;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ public class RenderBlockEntity extends Render<Entity>
|
|||
// float f2 = (1.0F - ((float)entity.fuse - partialTicks + 1.0F) / 100.0F) * 0.8F;
|
||||
this.bindEntityTexture(entity);
|
||||
GL11.glTranslatef(-0.5F, -0.5F, 0.5F);
|
||||
Client.CLIENT.renderer.renderBlockEntity(this.state, entity.getBrightness(partialTicks));
|
||||
Client.CLIENT.renderer.renderBlockEntity(this.state, getBrightness(entity));
|
||||
GL11.glTranslatef(0.0F, 0.0F, 1.0F);
|
||||
|
||||
// if (entity.fuse / 5 % 2 == 0)
|
||||
|
|
|
@ -44,7 +44,7 @@ public abstract class RenderLiving<T extends EntityLiving> extends RendererLivin
|
|||
}
|
||||
|
||||
public void setLightmap(T entity, float partial) {
|
||||
int l = entity.getBrightnessForRender(partial);
|
||||
int l = RenderManager.getBrightnessForRender(entity);
|
||||
int a = l % 65536;
|
||||
int b = l / 65536;
|
||||
GL13.glMultiTexCoord2f(GL13.GL_TEXTURE1, (float)a / 1.0F, (float)b / 1.0F);
|
||||
|
|
|
@ -20,6 +20,7 @@ import common.collect.Maps;
|
|||
import common.entity.Entity;
|
||||
import common.entity.types.EntityLiving;
|
||||
import common.init.SpeciesRegistry.ModelType;
|
||||
import common.util.BlockPos;
|
||||
import common.util.BoundingBox;
|
||||
import common.util.Vec3;
|
||||
import common.world.World;
|
||||
|
@ -119,6 +120,11 @@ public class RenderManager {
|
|||
return render != null && render.shouldRender(entityIn, camX, camY, camZ);
|
||||
}
|
||||
|
||||
public static int getBrightnessForRender(Entity entity) {
|
||||
BlockPos pos = new BlockPos(entity.posX, entity.posY + (double)entity.getEyeHeight(), entity.posZ);
|
||||
return entity.worldObj.isBlockLoaded(pos) ? entity.worldObj.getCombinedLight(pos, 0) : 0;
|
||||
}
|
||||
|
||||
public boolean renderEntity(Entity entity, float partialTicks) {
|
||||
if(entity.ticksExisted == 0) {
|
||||
entity.lastTickPosX = entity.posX;
|
||||
|
@ -129,7 +135,7 @@ public class RenderManager {
|
|||
double d0 = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double)partialTicks;
|
||||
double d1 = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double)partialTicks;
|
||||
double d2 = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * (double)partialTicks;
|
||||
int i = entity.getBrightnessForRender(partialTicks);
|
||||
int i = getBrightnessForRender(entity);
|
||||
|
||||
if(entity.isBurning()) {
|
||||
i = 15728880;
|
||||
|
|
|
@ -124,7 +124,7 @@ public class RenderMinecart<T extends EntityCart> extends Render<T>
|
|||
protected void func_180560_a(T minecart, float partialTicks, State state)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
Client.CLIENT.renderer.renderBlockEntity(state, minecart.getBrightness(partialTicks));
|
||||
Client.CLIENT.renderer.renderBlockEntity(state, getBrightness(minecart));
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public class RenderTntPrimed extends Render<EntityTnt>
|
|||
this.bindEntityTexture(entity);
|
||||
GL11.glTranslatef(-0.5F, -0.5F, 0.5F);
|
||||
Block tnt = BlockRegistry.byName("tnt" + (entity.explosionSize <= 0 || entity.explosionSize >= 8 ? "" : "_" + entity.explosionSize));
|
||||
renderer.renderBlockEntity(tnt.getState(), entity.getBrightness(partialTicks));
|
||||
renderer.renderBlockEntity(tnt.getState(), getBrightness(entity));
|
||||
GL11.glTranslatef(0.0F, 0.0F, 1.0F);
|
||||
|
||||
if (entity.fuse / 5 % 2 == 0)
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package client.renderer.entity;
|
||||
|
||||
import client.renderer.GlState;
|
||||
import client.renderer.layers.LayerWolfCollar;
|
||||
import client.renderer.model.ModelBase;
|
||||
import common.entity.animal.EntityWolf;
|
||||
|
@ -26,20 +25,6 @@ public class RenderWolf extends RenderLiving<EntityWolf>
|
|||
return livingBase.getTailRotation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the desired {@code T} type Entity.
|
||||
*/
|
||||
public void doRender(EntityWolf entity, double x, double y, double z, float partialTicks)
|
||||
{
|
||||
if (entity.isWolfWet())
|
||||
{
|
||||
float f = entity.getBrightness(partialTicks) * entity.getShadingWhileWet(partialTicks);
|
||||
GlState.color(f, f, f, 1.0F);
|
||||
}
|
||||
|
||||
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.
|
||||
*/
|
||||
|
|
|
@ -29,7 +29,7 @@ public class RenderXp extends Render<EntityXp> {
|
|||
float bx = 1.0F;
|
||||
float dx = 0.5F;
|
||||
float dy = 0.25F;
|
||||
int light = entity.getBrightnessForRender(partial);
|
||||
int light = RenderManager.getBrightnessForRender(entity);
|
||||
int block = light % 65536;
|
||||
int sky = light / 65536;
|
||||
GL13.glMultiTexCoord2f(GL13.GL_TEXTURE1, (float)block / 1.0F, (float)sky / 1.0F);
|
||||
|
|
|
@ -157,10 +157,7 @@ public class ModelWolf extends ModelBase
|
|||
this.wolfLeg4.rotateAngleX = ExtMath.cos(p_78086_2_ * 0.6662F) * 1.4F * p_78086_3_;
|
||||
}
|
||||
|
||||
this.wolfHeadMain.rotateAngleZ = wolf.getInterestedAngle(partialTickTime) + wolf.getShakeAngle(partialTickTime, 0.0F);
|
||||
this.wolfMane.rotateAngleZ = wolf.getShakeAngle(partialTickTime, -0.08F);
|
||||
this.wolfBody.rotateAngleZ = wolf.getShakeAngle(partialTickTime, -0.16F);
|
||||
this.wolfTail.rotateAngleZ = wolf.getShakeAngle(partialTickTime, -0.2F);
|
||||
this.wolfHeadMain.rotateAngleZ = wolf.getInterestedAngle(partialTickTime);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue