11package gregtech .client .renderer .texture .custom ;
22
33import gregtech .client .renderer .texture .Textures ;
4- import gregtech .client .texture .IconRegistrar ;
54import gregtech .common .metatileentities .MetaTileEntityClipboard ;
65
76import net .minecraft .client .Minecraft ;
1211import net .minecraft .client .renderer .texture .TextureMap ;
1312import net .minecraft .util .EnumFacing ;
1413import net .minecraft .util .ResourceLocation ;
14+ import net .minecraft .world .World ;
1515import net .minecraftforge .fml .common .FMLCommonHandler ;
1616import net .minecraftforge .fml .relauncher .Side ;
1717import net .minecraftforge .fml .relauncher .SideOnly ;
1818
1919import codechicken .lib .render .CCRenderState ;
2020import codechicken .lib .render .pipeline .IVertexOperation ;
21+ import codechicken .lib .texture .TextureUtils .IIconRegister ;
2122import codechicken .lib .vec .Cuboid6 ;
2223import codechicken .lib .vec .Matrix4 ;
2324import codechicken .lib .vec .Rotation ;
2425import org .apache .commons .lang3 .tuple .Pair ;
25- import org .jetbrains .annotations .NotNull ;
2626
2727import java .util .Arrays ;
2828import java .util .HashMap ;
2929import java .util .List ;
3030
31- public class ClipboardRenderer implements IconRegistrar {
31+ public class ClipboardRenderer implements IIconRegister {
3232
3333 private static final Cuboid6 pageBox = new Cuboid6 (3 / 16.0 , 0.25 / 16.0 , 0.25 / 16.0 , 13 / 16.0 , 14.25 / 16.0 ,
3434 0.3 / 16.0 );
@@ -58,7 +58,7 @@ public ClipboardRenderer() {
5858
5959 @ Override
6060 @ SideOnly (Side .CLIENT )
61- public void registerIcons (@ NotNull TextureMap textureMap ) {
61+ public void registerIcons (TextureMap textureMap ) {
6262 this .textures [0 ] = textureMap .registerSprite (new ResourceLocation ("gregtech:blocks/clipboard/wood" ));
6363 boxTextureMap .put (boardBox , this .textures [0 ]);
6464 this .textures [1 ] = textureMap .registerSprite (new ResourceLocation ("gregtech:blocks/clipboard/clip" ));
@@ -74,7 +74,8 @@ public static void renderBoard(CCRenderState renderState, Matrix4 translation, I
7474 translation .translate (0.5 , 0.5 , 0.5 );
7575 translation .rotate (Math .toRadians (90.0 * rotations .indexOf (rotation )), Rotation .axes [1 ]);
7676 translation .translate (-0.5 , -0.5 , -0.5 );
77-
77+ World world = clipboard .getWorld ();
78+ if (world != null ) renderState .setBrightness (world , clipboard .getPos ());
7879 // Render Clipboard
7980 for (EnumFacing renderSide : EnumFacing .VALUES ) {
8081 boxTextureMap .forEach ((box , sprite ) -> Textures .renderFace (renderState , translation , pipeline , renderSide ,
@@ -89,7 +90,17 @@ public static void renderGUI(double x, double y, double z, EnumFacing rotation,
8990 GlStateManager .pushMatrix ();
9091 float lastBrightnessX = OpenGlHelper .lastBrightnessX ;
9192 float lastBrightnessY = OpenGlHelper .lastBrightnessY ;
92- OpenGlHelper .setLightmapTextureCoords (OpenGlHelper .lightmapTexUnit , 240.0F , 240.0F );
93+
94+ float lx = 240 , ly = 240 ;
95+ World world = clipboard .getWorld ();
96+ if (world != null ) {
97+ int light = world .getCombinedLight (clipboard .getPos (), 0 );
98+
99+ lx = (float ) light % 0x10000 ;
100+ ly = (float ) light / 0x10000 ;
101+ }
102+
103+ OpenGlHelper .setLightmapTextureCoords (OpenGlHelper .lightmapTexUnit , lx , ly );
93104 RenderHelper .disableStandardItemLighting ();
94105
95106 // All of these are done in reverse order, by the way, if you're reviewing this :P
0 commit comments