Skip to content

Commit ead2095

Browse files
authored
Fix clipboard always rendered at full brightness (#2845)
1 parent 979b90b commit ead2095

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/main/java/gregtech/client/renderer/texture/custom/ClipboardRenderer.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import net.minecraft.client.renderer.texture.TextureMap;
1313
import net.minecraft.util.EnumFacing;
1414
import net.minecraft.util.ResourceLocation;
15+
import net.minecraft.world.World;
1516
import net.minecraftforge.fml.common.FMLCommonHandler;
1617
import net.minecraftforge.fml.relauncher.Side;
1718
import net.minecraftforge.fml.relauncher.SideOnly;
@@ -74,7 +75,8 @@ public static void renderBoard(CCRenderState renderState, Matrix4 translation, I
7475
translation.translate(0.5, 0.5, 0.5);
7576
translation.rotate(Math.toRadians(90.0 * rotations.indexOf(rotation)), Rotation.axes[1]);
7677
translation.translate(-0.5, -0.5, -0.5);
77-
78+
World world = clipboard.getWorld();
79+
if (world != null) renderState.setBrightness(world, clipboard.getPos());
7880
// Render Clipboard
7981
for (EnumFacing renderSide : EnumFacing.VALUES) {
8082
boxTextureMap.forEach((box, sprite) -> Textures.renderFace(renderState, translation, pipeline, renderSide,
@@ -89,7 +91,17 @@ public static void renderGUI(double x, double y, double z, EnumFacing rotation,
8991
GlStateManager.pushMatrix();
9092
float lastBrightnessX = OpenGlHelper.lastBrightnessX;
9193
float lastBrightnessY = OpenGlHelper.lastBrightnessY;
92-
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0F, 240.0F);
94+
95+
float lx = 240, ly = 240;
96+
World world = clipboard.getWorld();
97+
if (world != null) {
98+
int light = world.getCombinedLight(clipboard.getPos(), 0);
99+
100+
lx = (float) light % 0x10000;
101+
ly = (float) light / 0x10000;
102+
}
103+
104+
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lx, ly);
93105
RenderHelper.disableStandardItemLighting();
94106

95107
// All of these are done in reverse order, by the way, if you're reviewing this :P

0 commit comments

Comments
 (0)