mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 08:17:35 +00:00
This commit is contained in:
1 parent
d26cdf0b55
commit
83ab7656c9
3 files changed
+22
-3
No files matched your search
@@ -38,9 +38,10 @@ public class FlatQuadLighter extends QuadLighter
|
||||
isFullCube = Block.isShapeFullBlock(state.getCollisionShape(level, pos));
|
||||
for (Direction side : SIDES)
|
||||
{
|
||||
packedLight[side.ordinal()] = LevelRenderer.getLightColor(level, pos.relative(side));
|
||||
packedLight[side.ordinal()] = getLightColor(level, pos.relative(side), state);
|
||||
}
|
||||
packedLight[6] = LevelRenderer.getLightColor(level, pos);
|
||||
//Note: We can just use the LevelRenderer method as we know the state is the state at the given position
|
||||
packedLight[6] = LevelRenderer.getLightColor(level, state, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,9 +8,11 @@ package net.minecraftforge.client.model.lighting;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import net.minecraft.client.color.block.BlockColors;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.BlockAndTintGetter;
|
||||
import net.minecraft.world.level.LightLayer;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
@@ -150,4 +152,20 @@ public abstract class QuadLighter
|
||||
float yFactor = constantAmbientLight ? 0.9F : ((3.0F + normalY) / 4.0F);
|
||||
return Math.min(normalX * normalX * 0.6F + normalY * normalY * yFactor + normalZ * normalZ * 0.8F, 1.0F);
|
||||
}
|
||||
|
||||
/**
|
||||
* Note: This method is subtly different than {@link net.minecraft.client.renderer.LevelRenderer#getLightColor(BlockAndTintGetter, BlockState, BlockPos)}
|
||||
* as it only uses the state for querying if the state has emissive rendering but instead looks up the state at the given position for checking the
|
||||
* light emission.
|
||||
*/
|
||||
protected static int getLightColor(BlockAndTintGetter level, BlockPos pos, BlockState state)
|
||||
{
|
||||
if (state.emissiveRendering(level, pos))
|
||||
{
|
||||
return LightTexture.FULL_BRIGHT;
|
||||
}
|
||||
int skyLight = level.getBrightness(LightLayer.SKY, pos);
|
||||
int blockLight = Math.max(level.getBrightness(LightLayer.BLOCK, pos), level.getBlockState(pos).getLightEmission(level, pos));
|
||||
return skyLight << 20 | blockLight << 4;
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,7 @@ public class SmoothQuadLighter extends QuadLighter
|
||||
pos.setWithOffset(origin, x - 1, y - 1, z - 1);
|
||||
BlockState neighborState = level.getBlockState(pos);
|
||||
t[x][y][z] = neighborState.getLightBlock(level, pos) < 15;
|
||||
int brightness = LevelRenderer.getLightColor(level, pos);
|
||||
int brightness = getLightColor(level, pos, state);
|
||||
s[x][y][z] = LightTexture.sky(brightness);
|
||||
b[x][y][z] = LightTexture.block(brightness);
|
||||
ao[x][y][z] = neighborState.getShadeBrightness(level, pos);
|
||||
|
||||
Reference in new issue
Block a user